user3684678
user3684678

Reputation: 561

android.database.sqlite.SQLiteException: near "where": syntax error (code 1):

I am gettingandroid.database.sqlite.SQLiteException: near "where": syntax error (code 1): exception in the below code..Where i am going wrong?

String selectQuery = "SELECT  * FROM " + TABLE_VIDEO + " order by " + KEY_TIMESTAMP + " ASC "+"where " + KEY_TYPE + "='trending'";

Upvotes: 1

Views: 1289

Answers (3)

Phantômaxx
Phantômaxx

Reputation: 38098

ORDER BY must be the last SQL clause in your query.
So, it must come after the WHERE condition.

Upvotes: 4

Carlos Carrizales
Carlos Carrizales

Reputation: 2340

may be the:

/*code*/+ " ASC "+"where "+ /*morecode*/ 

try:

 /*code*/+ " ASC WHERE "+ /*morecode*/

Upvotes: -1

Derek W
Derek W

Reputation: 10026

ORDER BY must come after WHERE in the SELECT statement.

See here for more details.

Upvotes: 1

Related Questions