select * from A表 where id not in (select id from A表 left join B表 on A表.COL1 = B表.COL1)

解决方案 »

  1.   

    select * from A where COL1+COL2+COL3 not in(select COL1+COL2+COL3 from B)
      

  2.   

    修改下
    select * from A where COL1+COL2+COL3 not in(select COL1+COL2+COL3 from B where col1=A.col1)
      

  3.   

    再看了下,还是select * from A where COL1+COL2+COL3 not in(select COL1+COL2+COL3 from B)合楼主要求
      

  4.   

    Table A: 
    COL1    COL2  COL3 
    15504 43901 17043 
    15504 43901 20920 Table B: 
    COL1    COL2    COL3 
    15504 43901 17043 
    如何使结果集跳出 
    15504 43901 20920 
    这条记录
    一般对于一个字段我们都知道用in,not in ,exist等
    对于多个字段我们却不可以,但可以变通,合为一个字段处理
    select * 
    from A
    where A.COL1 + '_' + A.COL2 + '_' + A.COL3 not in 
    (select COL1 + '_' + COL2 + '_' + COL3  as newcol
    from B)
      

  5.   

    错了 应该是select A表.*,B表.id from A表 where id not in (select id from A表 left join B表 on A表.COL1 = B表.COL1 ) and B表.id is not null