任何人都可以帮助我:android.database.sqlite.SQLiteException: near ",": syntax error (code 1): ,
May any one please help me: android.database.sqlite.SQLiteException: near ",": syntax error (code 1): ,
请解决我的问题:
这是代码行
Cursor cursor = db.rawQuery("select * from Overhead_Table where IDNO="+incomingrecord[0]+" AND DATE_TIME LIKE "+DTTIME+"%" ,null);
我也试过:
Cursor cursor = db.rawQuery("select * from Overhead_Table where IDNO=? AND DATE_TIME LIKE ?%" ,new String[] {incomingrecord[0],DTTIME});
和
Cursor cursor = db.rawQuery("select * from Overhead_Table where IDNO=? AND DATE_TIME LIKE ?" ,new String[] {incomingrecord[0],DTTIME+"%"});
但是显示错误
android.database.sqlite.SQLiteException: near ",": syntax error (code
1): , while compiling: select * from Overhead_Table where
IDNO=6765456765 AND DATE_TIME LIKE 14,01,2021
始终使用 ?
占位符:
String sql = "SELECT * FROM Overhead_Table WHERE IDNO = ? AND DATE_TIME LIKE ? || '%'";
Cursor cursor = db.rawQuery(sql , new String[] {incomingrecord[0], DTTIME});
我假设 incomingrecord[0]
和 DTTIME
都是字符串。
请解决我的问题: 这是代码行
Cursor cursor = db.rawQuery("select * from Overhead_Table where IDNO="+incomingrecord[0]+" AND DATE_TIME LIKE "+DTTIME+"%" ,null);
我也试过:
Cursor cursor = db.rawQuery("select * from Overhead_Table where IDNO=? AND DATE_TIME LIKE ?%" ,new String[] {incomingrecord[0],DTTIME});
和
Cursor cursor = db.rawQuery("select * from Overhead_Table where IDNO=? AND DATE_TIME LIKE ?" ,new String[] {incomingrecord[0],DTTIME+"%"});
但是显示错误
android.database.sqlite.SQLiteException: near ",": syntax error (code 1): , while compiling: select * from Overhead_Table where IDNO=6765456765 AND DATE_TIME LIKE 14,01,2021
始终使用 ?
占位符:
String sql = "SELECT * FROM Overhead_Table WHERE IDNO = ? AND DATE_TIME LIKE ? || '%'";
Cursor cursor = db.rawQuery(sql , new String[] {incomingrecord[0], DTTIME});
我假设 incomingrecord[0]
和 DTTIME
都是字符串。