表一:
CODE    NUM
-----------
001     7
001     10
002     1
002     5
003     5
003     7
表二:
CODE    NUM
-----------
001     7
001     10
003     5
在不可改变表结构的前提下... 
求查询语句: 选出 同时满足 表一的CODE不在表二&表一的NUM不在表二中.执行的结果是:CODE    NUM
-----------
002     1
002     5
003     7

解决方案 »

  1.   

    select * from 表1 a where not exists (select 1 from 表2 b where a.code=b.code and a.num=b.num)
      

  2.   

    --试试,没测试过
    select * from tab1 a where not exists(select 1 from tab2 where code=a.code) or not exists(select 1 from tab2 where a.code=code and a.num=num)
      

  3.   


    csdn 又乱了  
    -1
    select * from tb1 minus select * from tb2
    -2
    select * from tb1 a where not exists(select 1 from tb2 b where a.code=b.code and a.num=b.num)