我正在尝试此查询:
Cursor c = myDB.rawQuery("SELECT * FROM " + tableName + " WHERE Field5 NOT LIKE " +
Arrays.toString(ALQu.toArray()).replace("[", "(").replace("]", ")") +
"ORDER BY RANDOM() LIMIT 1", null);
但是我收到以下错误:
03-12 18:12:34.469: E/AndroidRuntime(16604): android.database.sqlite.SQLiteException: near ",": syntax error: , while compiling: SELECT * FROM TableQ WHERE Field5 NOT LIKE (6, 9) ORDER BY RANDOM() LIMIT 1
我尝试排除已经检查过的字段。我在ArrayList中添加数据。我不知道问题出在哪里。你能帮忙吗?
编辑:
是的,它不在",我不知道为什么我没有尝试,谢谢
答案 0 :(得分:0)
改变NOT LIKE到NOT IN:
Cursor c = myDB.rawQuery("SELECT * FROM " + tableName + " WHERE Field5 NOT IN " +
Arrays.toString(ALQu.toArray()).replace("[", "(").replace("]", ")") +
"ORDER BY RANDOM() LIMIT 1", null);