android - SQLite Query execution condition error -


sqlite query not showing correct answer. error in query.

 "select distinct bike_reg_number bookings vendor_id = '"+id+"' , "+             "bike_reg_number = '"+temp+"' , (( from_date > '"+from_dt+"' , from_date > '"+              todt+"') or "+ "(to_date < '"+from_dt+"' , to_date < '"+todt+"'))"; 

my condition is,

(vendor_id must there) ,  (bike_reg_number must there) , (from_date must > given both input from_dt , todt) or (to_date must < given both input from_dt , todt) 

edit :

many bookings available particular vehicle(aa-01-1000). lets say,

(2016-02-06 2016-02-06), (2016-02-11 2016-02-11), (2016-02-15 2016-02-16), (2016-02-19 2016-02-20) 

i wanted know whether (aa-01-1000) vehicle available for(2016-02-08 2016-02-09). return correctly. if give (2016-02-17 2016-02-19) showing wrong. why because 1 record wrong. other record true value shows vehicle number.

actually don't want display vehicle name if 1 of condition fails in bookings table. so, sqlite possible? spent more time fix bug. still not fixed.

"select distinct bike_reg_number bookings vendor_id = '" + id + "' , bike_reg_number = '" + temp + "'"; 

retrieved data , manipulated in java date comparison. query can't do, decided date comparison java code.

 cursor cursor1 = db.rawquery(selectquery1, null);     if (cursor1.movetofirst()) {         string[] vehicle_number=new string[cursor1.getcount()];         string[] from_date=new string[cursor1.getcount()];         string[] to_date=new string[cursor1.getcount()];         int i=0;             {             vehicle_number[i]=(cursor1.getstring(0));             from_date[i]=(cursor1.getstring(1));//dummy             to_date[i]=(cursor1.getstring(2));//dummy             i++;             } while (cursor1.movetonext());             try {                 string vehi=getdatecomparison(vehicle_number,from_date,to_date,from_inp,to_inp);                 vehiclegetsetter contact = new vehiclegetsetter();                 contact.setnumber(vehi);                 contactlist1.add(contact);             } catch (parseexception e) {                 e.printstacktrace();             }         }     }       private string getdatecomparison(string[] veh, string[] from, string[] to,string from1, string to1) throws parseexception {        simpledateformat df = new simpledateformat("yyyy-mm-dd",locale.english);        date table_from,table_to,input_from,input_to;        long diff=0,diff1=0,diff2=0,diff3=0;        int count=0,county=0;;        string vehic="";        for(int i=0;i<veh.length;i++){           table_from=df.parse(from[i]);           table_to=df.parse(to[i]);           input_from=df.parse(from1);           input_to=df.parse(to1);           table_from=df.parse(df.format(table_from));           table_to=df.parse(df.format(table_to));           input_from=df.parse(df.format(input_from));           input_to=df.parse(df.format(input_to));           diff=table_from.gettime()-input_from.gettime();           diff1=table_from.gettime()-input_to.gettime();           diff2=input_from.gettime()-table_to.gettime();           diff3=input_to.gettime()-table_to.gettime();           if((diff > 0 && diff1>0) || (diff2 > 0 && diff3>0)){             count++;             log.d("date", " ok from");           }          else             county=100;        }        if(county==100)           return vehic;        else           vehic= veh[0];        return vehic;      } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -