Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql - UPDATE with LIMIT x, y

Tags:

mysql

UPDATE table SET checked = 1 WHERE field = 'xxx' LIMIT 1

works fine, but

UPDATE table SET checked = 1 WHERE field = 'xxx' LIMIT 1, 10

throw error "#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 ' 10' at line 1"

Why it is not possible? I want to update everything except first row.

like image 305
Qiao Avatar asked Dec 07 '22 22:12

Qiao


1 Answers

update table set checked = 1 where id in (select * from (select id from table where field = 'xxx' order by id limit 1, 10) as t)
like image 185
Nicola Cossu Avatar answered Dec 10 '22 11:12

Nicola Cossu