mysql表中批量更新字段順序加1

採用臨時表的方式

create table test_temp (
id int primary key auto_increment,
tid bigint 
) ;

 


insert into test_temp (tid) 
select id from table_1;

 

update table_1 f,test_temp t  set sort_num=t.id where f.id = t.tid;

select sort_num From table_1;

 

drop table test_temp ;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章