select A.*,B.*
from table1 A full join table2 B on B.id=A.id

解决方案 »

  1.   

    select a.id from table1 a where exists(select 1 from table2 where id=a.id)
      

  2.   

    to progress99(如履薄冰)
    我想把两张表中的Id 放在一个字段中显示
      

  3.   

    樓主是隻要id字段嗎?
    select A.id
    from table1 A inner join table2 B on B.id=A.id
      

  4.   

    用內聯接:
    select A.id,A.name,B.address
    from table1 A inner join table2 B on B.id=A.id
      

  5.   

    select a.id from table1 a inner join table2 b on a.id = b.id
      

  6.   

    to zjcxc(: 邹建 :) 
    我想把两张表中的Id 放在一个字段中显示
      

  7.   

    to progress99(如履薄冰)
    是的只要ID,要两张表中ID的所有值
      

  8.   


    select a.id from table1 a inner join table2 b on a.id=b.id
      

  9.   

    這樣就可以了:
    select A.id
    from table1 A inner join table2 B on B.id=A.id
      

  10.   

    to progress99(如履薄冰)
    select A.id,A.name,B.address
    from table1 A inner join table2 B on B.id=A.id
    这样只能得到两张表中想同的ID
      

  11.   

    內聯接參保証到兩表的id相同時才select 出來。
      

  12.   

    to shuichangliu(生活一定会越来越好!)
    select a.id from table1 a inner join table2 b on a.id=b.id
    不能得到所有的ID
      

  13.   

    to progress99(如履薄冰) 
    我想取出所有的,包括相同的和不同的
      

  14.   

    還是要笛卡爾積:
    select distinct A.id
    from table1 ,table2
      

  15.   

    就用這個,你先試試
    select distinct A.id
    from table1 ,table2
      

  16.   

    to progress99(如履薄冰)
    笛卡爾積不能得出ID的所有值
      

  17.   

    --原来搞错你的意思,你是想将两张表中所有的ID取出来,而且不重复,是否这个意思?select id from table1
    union
    select id from table2
      

  18.   

    懂了,你是要這個:select id
    from table1
    union 
    select id
    from table2
      

  19.   

    to zjcxc(: 邹建 :) 
    是的
      

  20.   

    to progress99(如履薄冰) zjcxc(: 邹建 :) 
    谢谢