Yoav
Yoav

Reputation: 11

Android SQL problem

I have this sql statement

SELECT *
  FROM RecipeInstructions
 ORDER BY INSTRUCTION_NUMBER ASC
 WHERE RECIPE_ID_FK=1

execute it using rawquery - have exception... Syntax error near WHERE... Why?

Upvotes: 1

Views: 67

Answers (3)

Cedekasme
Cedekasme

Reputation: 2037

You should try this instead:

SELECT * FROM RecipeInstructions WHERE RECIPE_ID_FK=1 ORDER BY INSTRUCTION_NUMBER ASC

Upvotes: 0

Adam V
Adam V

Reputation: 6356

Just a guess, but shouldn't the WHERE be before the ORDER BY?

Upvotes: 1

Sparky
Sparky

Reputation: 15095

WHERE needs to come before ORDER BY

SELECT * FROM RecipeInstructions
WHERE RECIPE_ID_FK=1
ORDER BY INSTRUCTION_NUMBER ASC 

Upvotes: 3

Related Questions