其他的方法或者函数我就不清楚了,不过我试过这样可以实现你想的效果,就是先id的主键,然后增加一个字段newid int not null auto_increment primary key,接着用count(*)计算出所有的记录数total,再写一个储存过程插入newid的序号,用上面的total作为循环的上限

解决方案 »

  1.   

    用一个临时表或缓冲表
    1、将数据排好序插入临时表或缓冲表 insert into tb select ....
    2、将原表删除,再重建表 drop table , create table...
    3、将数据再插入新表 insert into tb select ....
    4、删除临时表,或清空缓冲表 drop table ,delete from table...全部过程用事务控制,虽然可行,不过效率可能不太行
      

  2.   

    truncate 这个还真不知道啊....学习
      

  3.   

    ALTER  TABLE  tablename  AUTO_INCREMENT  =  1
      

  4.   

    还是mathematician(数学家) 强啊
      

  5.   

    mathematician(数学家)很高!!
    michael_g_hu(一代风云),我正是想用入库时间排序,有什么好办法吗?难道做循环吗?可以用一条sql实现吗?
      

  6.   

    select (@i:=@i+1) as i,table_name.* from table_name,(select @i:=0) as it order by 入库时间