select * from key not in (select a.key from table1 a join table2 b
on  a.code=b.code and a.spec =b.spec)

解决方案 »

  1.   

    不号意思,法错了。改改
    select * from table1 key not in (select a.key from table1 a join table2 b
    on  a.code=b.code and a.spec =b.spec)
      

  2.   

    select * from table1 where key not in (select a.key from table1 a join table2 b
    on  a.code=b.code and a.spec =b.spec)
      

  3.   

    select a.* from  table1 a
    left join table2 b on a.code = b.code and a.spec = b.spec
    where b.code is null or b.spec is null
      

  4.   

    select * from table1 where key not in (select table2.key from table2 where table2.code=table1.code and table2.spec=table1.spec)
      

  5.   

    select * from table1 a 
          where not exists 
          (
                select * from table2 b 
                       where a.code=b.code and a.spec=b.spec
          )