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'";
0

3 Answers 3

4

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

Sign up to request clarification or add additional context in comments.

2 Comments

Suggestion for improvement: What you are saying here is technically untrue as LIMIT comes after ORDER BY in the SELECT statement.
Yep, true. I wasn't considering that. Edited.
1

ORDER BY must come after WHERE in the SELECT statement.

See here for more details.

Comments

-1

may be the:

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

try:

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

4 Comments

What does it change? The result would be the same: ASC WHERE. Only the execution speed will be faster (about 0.001 nanosecond?) in the second case, because of one less string concatenation.
you are right, but i just want to help, nothing more, see ya
Well, you did not, sorry.
Really, this post provides no answer at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.