select a from t
union
select b from t
union
select c from t
union
select d from t

解决方案 »

  1.   

    select distinct a from (select a from table1
    union 
    select b from table1
    union 
    select c from table1
    union 
    select d from table1
    ) t1
      

  2.   

    select a from table1
    union 
    select b from table1
    union 
    select c from table1
    union 
    select d from table1
      

  3.   

    -- union已经去掉了重复值,所以不需要再次查询了。
    -- test:
    create table #t(a varchar(10),b varchar(10),c varchar(10),d varchar(10))
    insert #tselect 'aa','bb','bb','dd'select distinct a 
    from 
    (
    select a from #t
    union all
    select b from #t
    union all
    select c from #t
    union all
    select d from #t
    ) t-- orselect a from #t
    union 
    select b from #t
    union 
    select c from #t
    union 
    select d from #tdrop table #t
      

  4.   

    用union得出两到三条记录,能否把最后的结果也就是aa,bb放在一个字段内显示