日期:2014-05-17  浏览次数:20362 次

求1条SQL,应该简单,但写不来.
表A
c_id     c_date
001      2010-01-01
001      2010-01-02
001      2010-01-03
002      2010-01-01
002      2010-01-02
002      2010-01-03

表B
c_id     c_date
001      2010-01-01
001      2010-01-03
002      2010-01-01
002      2010-01-02
--------------------------------
期望的结果(即A表有,B表没用的数据)
要求,不能用2个NOT IN 的方法.
c_id     c_date
001      2010-01-02
002      2010-01-03

------解决方案--------------------
参考:
http://www.cnblogs.com/aierong/archive/2008/08/25/1273831.html
------解决方案--------------------
引用:
SQL code?123    select a.*     from a left join b on a.c_id = b.c_id and a.c_date = b.c_date    where a.c_id is null

修改成

    select a.* 
    from a left join b on a.c_id = b.c_id and a.c_date = b.c_date
    where b.c_id is null