在update语句中 limit 前几条是没问题的,形如下面的写法
update temp_dj_purchase set flag = "1" limit 1000
对于特定情况下,需要分页update,使用其他字段作为筛选条件又不能完全筛选出中间的数据,这个时候需要写limit 10,1000,但是默认情况下会报错
[SQL]update temp_dj_purchase set flag = "1" limit 0, 1000
[Err] 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 ' 1000' at line 1
解决方案是使用子查询,改为下面的写法:
update temp_dj_purchase set flag = "1" where
id in (select id from
(select id from temp_dj_purchase
order by createtime asc limit 10, 1000)tmp)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)