multiple where clause in android
android, sqlite
Solution
Put some spaces around AND and add these "'" around after =:
String Reminder_Main="Reminder_Main",Car_ID="Car_ID",Reminder_Date="Reminder_Date";
Cursor c = sdb.rawQuery("select Reminder_Id ,Reminder_Type,Reminder_Date,Reminder_Time,Reminder_Alert from " + Reminder_Main
+" where " + Car_ID + " = ? AND " + Reminder_Date + " = ? " , new String[] { summaryid,currentdate1});
c.moveToFirst();
c.moveToFirst();
int summarycount = c.getCount();
If this is not enough to fix the problems, please refer to here https://stackoverflow.com/a/9061437/1503155 to clear up the remaining problem.
Problem
``` String slctsummary = "select Reminder_Id,Reminder_Type,Reminder_Date,Reminder_Time,Reminder_Alert from Reminder_Main where Car_ID=" +summaryid +"AND" +Reminder_Date +"=" +currentdate1; Cursor c = sdb.rawQuery(slctsummary,null); ``` i want all the records which satisfy both conditn but it through error. plz help me to com out of ths thnx... the log cat error........ ``` > 12-17 11:48:05.250: E/AndroidRuntime(1245): > java.lang.RuntimeException: Unable to start activity >ComponentInfo{com.curious.solutions.finalautoistdiary/com.curious.solutions.finalautoistdiary.ReminderSummary}: > android.database.sqlite.SQLiteException: unrecognized token: > "1ANDReminder_Date17": , while compiling: select > Reminder_Id,Reminder_Type,Reminder_Date,Reminder_Time,Reminder_Alert > from Reminder_Main where Car_ID=1ANDReminder_Date17-NOV-2012 ```