Why, when I try to do an order by query, do I always get an error telling me to check the syntax by the ORDER BY ‘order’ DESC?
Here’s my query:
SELECT * FROM posts ORDER BY order DESC;
What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
orderis a reserved word in SQL; case does not matter. It must be quoted when used as an identifier. From the MySQL Reserved Words documentation:Traditional MySQL quotes:
Proper (ANSI) SQL quotes (some databases support
[order]as well):Although I would consider renaming the column to avoid such confusing issues in the future.