Chad White
Chad White

Reputation: 309

sqlite exception error SELECT command

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);

Did not see the Point :( any help

Maybe there is a error in my Statement but it didn't work

Upvotes: 0

Views: 266

Answers (2)

Diego Torres Milano
Diego Torres Milano

Reputation: 69318

No comma after id and WERE should be WHERE. Also consider using [rawQuery()](http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#rawQuery(java.lang.String, java.lang.String[], android.os.CancellationSignal)] with selectionArgs to avoid having to concatenate query and values as you did in +id=+9.

Upvotes: 2

0x5050
0x5050

Reputation: 1231

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

'WERE' should be WHERE

Upvotes: 2

Related Questions