android.database.sqlite.SQLiteException:near“where”:语法错误(代码1):

时间:2015-03-10 19:36:37

标签: android database sqlite

我在下面的代码中遇到android.database.sqlite.SQLiteException: near "where": syntax error (code 1):异常。我哪里出错了?

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

3 个答案:

答案 0 :(得分:3)

ORDER BY必须是查询中的最后 SQL子句 因此,在之后必须

答案 1 :(得分:1)

ORDER BY必须在WHERE声明中SELECT之后。

有关详细信息,请参阅here

答案 2 :(得分:-1)

可能是:

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

尝试:

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