select a.t 
from (select parent_type,parent_type as t from article
      union all
      select parent_type,'   '+child_type  as t from article ) a
order by a.parent_type

解决方案 »

  1.   

    select a.t 
    from (select 1 as id,parent_type,parent_type as t from article
          union all
          select 2 as id,parent_type,'   '+child_type  as t from article ) a
    order by a.parent_type,id
      

  2.   

    行就是行,不行就是不行,怎么好像啊  你没试吧 
    select a.t 
    from (select 1 as id,parent_type,parent_type as t from article
          union all
          select 2 as id,parent_type,'   '+child_type  as t from article ) a
    order by a.parent_type,a.id
      

  3.   

    不行。t                                                                                                       
    ------------------------------------------------------------------------------------------------------- 
    .Net技术
    .Net技术
    .Net技术
       Asp.Net基础
       C#语言
       VB.net语言
    ASP技术
    ASP技术
    ASP技术
       ASP基础
       ASP应用
       ASP技巧(所影响的行数为 12 行)
      

  4.   

    http://www.cnblogs.com/goodspeed/archive/2004/09/16/43714.html
      

  5.   

    select a.t 
    from (select 1 as id,aa.parent_type,aa.parent_type as t 
          from (select distinct prent_type from article ) aa
          union all
          select 2 as id,parent_type,'   '+child_type  as t from article ) a
    order by a.parent_type,a.id
      

  6.   

    服务器: 消息 207,级别 16,状态 3,行 1
    列名 'prent_type' 无效。
    服务器: 消息 207,级别 16,状态 1,行 1
    列名 'parent_type' 无效。
    服务器: 消息 207,级别 16,状态 1,行 1
    列名 'parent_type' 无效。
      

  7.   

    select a.t 
    from (select 1 as id,aa.parent_type,aa.parent_type as t 
          from (select distinct parent_type from article ) aa  --这里列名写错了
          union all
          select 2 as id,parent_type,'   '+child_type  as t from article ) a
    order by a.parent_type,a.id
      

  8.   

    TO:lsxaa(小李铅笔刀) 我的表type还有很多记录,为什么能他不能显示呢?能不能让它显示。小弟是一个菜鸟!
      

  9.   

    create table #Type (id int, mc nvarchar(10))insert into #Type (id, mc) values (1, '.net')
    insert into #Type (id, mc) values (2, 'asp')
    create table #book(id int, type nvarchar(10), bookname nvarchar(20))
    insert into #book(id, type, bookname) values (1, '.net', 'C#1')
    insert into #book(id, type, bookname) values (1, '.net', 'C#2')
    insert into #book(id, type, bookname) values (1, '.net', 'C#3')
    insert into #book(id, type, bookname) values (1, 'asp', 'asp1')
    insert into #book(id, type, bookname) values (1, 'asp', 'asp2')select * from 
    (select 0 as xh,id, mc, '' as bookname, '' as id1, '' as type
     from #type
     union all
     select 1, * from #book, #type 
     where #book.type = #Type.mc) a
    order by mc, xhdrop table #Type
    drop table #book在我的机器上测试通过
      

  10.   

    select a.article,b.child_type from a inner join b on a.article_type=b.parent_type
    结果如下:
    .Net技术  Asp.Net基础
    .Net技术  C#语言
    .Net技术  VB.net语言      
    ASP技术  ASP基础
    ASP技术  ASP应用
    ASP技术  ASP技巧     
      

  11.   


    select a.t 
    from (select 1 as idd,article_type ,article_type as t from type
          union all
          select 2 as idd,parent_type,'   '+child_type  as t from article ) a
    order by a.parent_type,a.idd
      

  12.   


    select a.t 
    from (select 1 as idd,article_type as  parent_type,article_type as t from type
          union all
          select 2 as idd,parent_type,'   '+child_type  as t from article ) a
    order by a.parent_type,a.idd