採用臨時表的方式
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 ;