I am trying to query an SQLite table for a row which has the same day of the week between a start time and end time as follows:
String whereClause = String.format("%s = '?' AND %s <= '?' %s > '?'",
Shift.PROP_DAY_OF_THE_WEEK, Shift.PROP_START_TIME,
Shift.PROP_END_TIME);
String[] whereargs = new String[] { String.valueOf(dow), time, time };
Cursor cursor = db.rawQuery(whereClause, whereargs);
However I am getting the following Logcat error.
03-30 22:46:02.827: E/AndroidRuntime(11507): android.database.sqlite.SQLiteException: near "dayOfTheWeek": syntax error (code 1): , while compiling: dayOfTheWeek = '?' AND startTime <= '?' endTime > '?'
I have added the single quote(') to surround the question mark(?). It is not working without the single quote also. I have added them since sql statement can be sensitive to having the quote or not. If I am on the wrong track, please let me know.