有关SQLitedatabase的语法错误,何时是select * from

时间:2013-08-21 08:37:09

标签: android syntax-error

这是错误

  

android.database.sqlite.SQLiteException:靠近“FROMfriendsWHERE”:   语法错误:,编译时:SELECT * FROMfriendsWHERE id!=?

这是我的代码

Cursor cursor = db.rawQuery("SELECT * FROM "+FriendsDBHelper.TABLE_NAME+" WHERE id != ?",new String[]{Integer.toString(0)});

1 个答案:

答案 0 :(得分:0)

尝试

Cursor cursor = db.rawQuery("SELECT * FROM "+FriendsDBHelper.TABLE_NAME+" WHERE id NOT LIKE ?",new String[]{Integer.toString(0)});

NOT LIKE用于do not have ? value in it

或者

Cursor cursor = db.rawQuery("SELECT * FROM "+FriendsDBHelper.TABLE_NAME+" WHERE id <> ?",new String[]{Integer.toString(0)});

<>用于is not equal to ?