日期:2014-05-17 浏览次数:20787 次
SELECT * FROM LCD29 L WHERE L.LDCD291 >= TRUNC(SYSDATE, 'dd') AND L.GDAB056 NOT IN (SELECT B.BD_DATA5 FROM HR_COMBOOKDATE B WHERE B.BD_DATE >= TRUNC(SYSDATE, 'dd') AND TRUNC(L.LDCD291, 'dd') = TRUNC(B.BD_DATE, 'dd'));
SELECT L.* FROM LCD29 L inner join HR_COMBOOKDATE B on TRUNC(L.LDCD291, 'dd') = TRUNC(B.BD_DATE, 'dd') AND L.GDAB056 = B.BD_DATA5 WHERE L.LDCD291 >= TRUNC(SYSDATE, 'dd') and B.BD_DATE >= TRUNC(SYSDATE, 'dd');
------解决方案--------------------
SELECT 1更多的时候是用在NOT EXISTS,即不存在,不存在 符合
FROM HR_COMBOOKDATE B
WHERE B.BD_DATE >= TRUNC(SYSDATE, 'dd')
……
这些关联条件的记录。为了迎合sql语法,需要select一个字段,那么就select 1吧,当然,select 2 也可以。