按序号批量更新某个字段

use xfgs;
SET SQL_SAFE_UPDATES = 0;
SET @num = 0;
update xfgs.news_t t set t.orderNum= (@num := @num + 1)

按排序后更新

use xfgs;
SET SQL_SAFE_UPDATES = 0;
SET @num = 0;
update xfgs.news_t t set t.orderNum= (@num := @num + 1) order by createtime

猜你喜欢

转载自www.cnblogs.com/qingfenglin/p/10931081.html