例如表:table有十条记录;
连接后结果应该有20条记录:结果:
fields2
.
.
.
fields2
.
.
.

解决方案 »

  1.   

    select field1 from tablename
    union all
    select field2 from tablename
      

  2.   

    select 字段1 from 表
    union all
    select 字段2 from 表
      

  3.   

    同时进行,CSDN服务器不错
    2006-04-21 18:09:00 2006-04-21 18:09:00 
      

  4.   

    select column1 from tb
    union all 
    select column2 from tb
      

  5.   

    create table ta(id int,name nvarchar(5))
    insert into ta select 1,'a'
    union all select 2,'b'create table tb(id int,name nvarchar(5))
    insert into tb select 3,'C'
    union all select 4,'D'select * from ta
    union all 
    select * from tbdrop table ta
    drop table tb
    -----------------------(所影响的行数为 2 行)
    (所影响的行数为 2 行)id          name  
    ----------- ----- 
    1           a
    2           b
    3           C
    4           D(所影响的行数为 4 行)
      

  6.   

    谢谢各位.现在还想把此字段使用distinct().就是去掉重复的.有什么办法吗?
    还有,如果字段多了.这样的语句太长了.会不会有问题?
      

  7.   

    select * from ta
    union all 
    select * from tb这样一句,在两个表合并的时候,已经是做去重复处理了,除非你还有其它字段~
      

  8.   

    去重复的的话用
    select field1 from tablename
    union
    select field2 from tablename
      

  9.   

    去掉重复的,只要把union all 改为union 即可
      

  10.   

    借问一下,下列
    a 1
    b 2
    b 4
    b 3
    c 5
    c 7
    c 6
    c 9
    如何得到
    a 1
    b 243
    c 5769