Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't this SQL UPDATE query work?

Tags:

sql

mysql

I know SQL well but I must be missing something really dumb here. This update query keeps throwing an error. The query is:

UPDATE pages SET 'order' = 1 WHERE id = 19

The table definitely has a column for order, and it has a record with the ID of 19. The order column is not unique.

The error I get is the generic one:

#1064 - 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" = 2 WHERE id = 19' at line 1 

I've enclosed order in quotation marks because ORDER is a reserved SQL word. What am I missing?

like image 257
rhodesjason Avatar asked Mar 05 '10 07:03

rhodesjason


2 Answers

If using MySQL the query should look like this:

UPDATE `pages` SET `order`=1 WHERE `id`=19
like image 187
Tobias Avatar answered Oct 14 '22 17:10

Tobias


That looks like a MySQL error message. Doesn't MySQL use backticks (`) for escaping?

like image 23
Ken Avatar answered Oct 14 '22 17:10

Ken