sqlite异常错误SELECT命令

时间:2016-03-30 20:16:30

标签: android sqlite select

Caused by: android.database.sqlite.SQLiteException: near "FROM": syntax error (code 1): , while compiling: SELECT _id, FROM TRACKS WERE _id=9

 String test = "SELECT _id, FROM TRACKS WERE _id="+"9";

    Cursor cursor = database.rawQuery(test, null);

没看到点:(任何帮助

我的声明中可能存在错误但无效

2 个答案:

答案 0 :(得分:2)

  

SELECT _id,FROM TRACKS WERE _id =" +" 9"

'呈'应该是WHERE

答案 1 :(得分:2)

idWERE之后的逗号不应为WHERE。 还要考虑将[rawQuery()](http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#rawQuery(java.lang.String,java.lang.String [],android.os.CancellationSignal)]与selectionArgs一起使用,以避免像{{{1}中那样连接查询和值。 1}}。