简体   繁体   中英

Update the last 360 rows of a table mysql

I have 360 rows at the end of the table where I need to change the date from 2013-08-26 to 9999-12-31. I tried this query but got a syntax error.

UPDATE xxx_score
SET xxx_date_to = 9999-12-31
WHERE xxx_date_to = 2013-08-26
ORDER BY `xxx_score`.`xxx_id` DESC
LIMIT 0 , 360

but got

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 ' 360' at line 5

Any help please in where I am going wrong.

Dates should be enclosed in quotes as described here http://dev.mysql.com/doc/refman/5.1/en/date-and-time-literals.html

ORDER BY AND LIMIT are OK, as long as you don't JOIN .

Try changing LIMIT 0, 360 to LIMIT 360 .
You can use only row count after LIMIT in UPDATE: source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM