--try
select * from test order by cast(uid as int) 

解决方案 »

  1.   

    create table test 

    uid varchar(50), 
    uname varchar(50) 

    insert into test select
    '01  ','姓名' union all select 
    '0101','姓名' union all select 
    '0102','姓名' union all select 
    '0103','姓名' union all select 
    '03  ','姓名' union all select 
    '0301','姓名' union all select 
    '0302','姓名' union all select 
    '02  ','姓名' union all select 
    '0201','姓名' union all select 
    '0202','姓名' union all select 
    '10  ','姓名' union all select 
    '1001','姓名' union all select 
    '1002','姓名' select * from test order by uid 
    /*
    uid                                                uname                                              
    -------------------------------------------------- -------------------------------------------------- 
    01                                                 姓名
    0101                                               姓名
    0102                                               姓名
    0103                                               姓名
    02                                                 姓名
    0201                                               姓名
    0202                                               姓名
    03                                                 姓名
    0301                                               姓名
    0302                                               姓名
    10                                                 姓名
    1001                                               姓名
    1002                                               姓名(所影响的行数为 13 行)
    select * from test order by cast(uid as int)
    /*uid                                                uname                                              
    -------------------------------------------------- -------------------------------------------------- 
    01                                                 姓名
    02                                                 姓名
    03                                                 姓名
    10                                                 姓名
    0101                                               姓名
    0102                                               姓名
    0103                                               姓名
    0201                                               姓名
    0202                                               姓名
    0301                                               姓名
    0302                                               姓名
    1001                                               姓名
    1002                                               姓名(所影响的行数为 13 行)*/
    */
      

  2.   

    我这里执行也是没有问题的啊。试试杰伦的SELECT * FROM TEST ORDER BY CAST(ID AS INT)
      

  3.   

    我这里的结构是一个树形结构,如果转换为int型就完全打乱了我树形结构!
      

  4.   

    看看表结构,尤其是uid字段的类型和排序方式