https://blog.csdn.net/kriszhang/article/details/72125203
首先设置一个变量,初始值为0:
set @r:=0;
- 1
然后更新表中对应的ID列:
update tablename set id=(@r:=@r+1)
- 1
如果是插入,那就找一个记录多的表t1
set @r:=0;
insert into t select @r:[email protected]+1 from t1 limit 0, 2000
- 1
- 2
@完
原文地址:https://www.cnblogs.com/fengff/p/9579865.html
时间: 2024-11-08 20:47:38