select A.* from A join B on A.id=B.id

解决方案 »

  1.   

    升级一下你的mysql或者是换个4.1以上的版本。
      

  2.   

    这里主要不是想用联合查询,
    虽然下面
    select * from A
    where A.id in(select B.id from B)
    可以用联合查询来做,但是如果是下面的情况
    select * from A
    where A.id not in(select B.id from B)
    又该怎么做呢?
      

  3.   

    试试
    select * from A
    where id in(select id from B)
      

  4.   

    呵呵。我自己找到答案了。可以用以下做法:
    select A.* from A left join B
    on A.id=B.id
    where isnull(A.id)=1
      

  5.   

    还可以这样
    select * from A left join B on A.id=B.id where B.id is null