日期:2014-05-18  浏览次数:20419 次

这个结构如何得到?等待中
表:CTpye
结构:(T_ID(identity),T_Name(varchar),T_Father(int))
数据如:   1,交通工具,0
                  2,汽车,       1
                  3,火车,       1
                  4,IT,           0
                  5,硬件,       4
                  6,软件,       4
                  7,自行车       1
      ....................
怎么能得到如下的形式:
        T_ID,T_Name
        1,交通工具
        2,汽车
        3,火车
        4,自行车
        5,IT
        6,硬件
        7,软件
        4,IT

------解决方案--------------------
select * from 表 order by (case T_Father when 0 then T_ID else T_Father end),T_ID