2个表格数据结构相同,表A和表B
求一句SQL语句,要求:取表A的字段C与表B的字段C相同的两个表的数据的合并集合即:将A和B数据合并后,取字段C相同的数据这个SQL语句怎么写啊

解决方案 »

  1.   

    SELECT * FROM 表A A INNER JOIN 表B B ON A.字段C=B.字段C
      

  2.   

    SELECT * FROM 表A A INNER JOIN 表B B ON A.C=B.C
      

  3.   

    select A.* from A,B where A.c=B.c
    union all
    select B.* from A,B where B.c=A.c
      

  4.   

    select * from  A,B where A.C=B.C
      

  5.   

    create table A (
    id int,
    c varchar(20))create table B (
    id int,
    c varchar(20))insert A
    select 1,'tom'
    union all
    select 3,'jack'insert B
    select 2,'terry'
    union all
    select 4,'jack'select a.* from a,b where a.c=b.c
    union all
    select b.* from a,b where a.c=b.c
    drop table a
    drop table b
    结果
    3 jack
    4 jack
      

  6.   

    lang8134(heaton)的正确,其他的都不对看似简单其他的结果,都是横向字段合并的,记录数并不对