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