SELECT ID2 FROM (SQL2查询)A WHERE ID2 NOT IN(SELECT ID1 FROM (SQL1查询)B)

解决方案 »

  1.   

    not exists 就可以了。select *  from sql2 where id2 not exists(select id 1 from sql1) 
      

  2.   

    select * from table2 a where not exists(select * from table1 where a.id2=id1)
      

  3.   

    SELECT ID2 FROM (SQL2查询)A 
    left join (SQL1查询)B
    on a.id2 = b.id1
    WHERE b.id1 is null
      

  4.   

    select ID2 from SQL2 left outer join SQL1 on SQL2.id2 = SQL.id1 where SQL2.ID2 is null