日期:2014-05-16  浏览次数:20462 次

not exist, not in, left join 的写法,不在。。。之内
SELECT T2.DEPTNO
  FROM DEPT2 T2
 WHERE NOT EXISTS 
 (SELECT 1 FROM DEPT WHERE DEPT.DEPTNO = T2.DEPTNO)

 

SELECT T2.DEPTNO
FROM DEPT2 T2 
WHERE T2.DEPTNO NOT IN 
(SELECT T1.DEPTNO FROM DEPT T1); 

  

SELECT *
  FROM (SELECT T1.DEPTNO T12, T2.DEPTNO T22
          FROM DEPT2 T2
          LEFT JOIN DEPT T1 ON T1.DEPTNO = T2.DEPTNO)
 WHERE T12 IS NULL

?