按序号批量更新某个字段

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

posted @ 2019-05-27 15:43  清枫林  阅读(779)  评论(0编辑  收藏  举报