Why does this SQL select statement give an error ?

2.49K viewsProgrammingSQL troubleshooting
0

SELECT * from order;

The above query gives the below error :- 

mysql> show columns from order;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'order' at line 1

Answered question
0

You shouldn’t use Order as a name for a table as it’s a reserved word in SQL. However, if you have used it, for the above query to work, escape the table name using back-ticks like below and then it will work.

SELECT * from `order`;

Answered question
Write your answer.

Categories