I want to execute the following SQL query using SQLite's rawQuery() in Android.
But I am getting
"android.database.sqlite.SQLiteException: near "status": syntax error: , while compiling: select emp_id,start_date,end_date fromleave_plans1where status = ?"
SQL query : select emp_id,start_date,end_date from leave_plans where status="approved" or status="pending"
and rawQuery i have used :
db.rawQuery("select emp_id,start_date,end_date from" + TABLE_NAME + "where status = ?",new String[] {"approved","pending"});
Please help
Thanks
sneha
for string values it must like status='approved'
like this 'BID'
db_obj.rawQuery("select page_no from BOOK_MARKS where page_no= "+page + " and book_id= "+"'"+BID+"'", null);
or
I am not understanding why you are using like this
You can use
Try this code:
The two question marks are necessary in the third argument in the
query
call as each?
character references one element in thewhereArguments
array. So this call will translate to:SELECT emp_id, start_date, end_date FROM {TABLE_NAME} WHERE status = "approved" OR status = "pending";
(Where {TABLE_NAME} will obviously be replace by whatever String constant it represents.)