1、EXISTS的使用方法
EXISTS 是判断是否存在,和in类似,但效率要比in高 SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND EXISTS (SELECT ‘X‘ FROM DEPT WHERE DEPT.DEPTNO = EMP.DEPTNO AND LOC = ‘MELB‘) SELECT * FROM EMP (基础表) WHERE EMPNO > 0 AND DEPTNO IN(SELECT DEPTNO FROM DEPT WHERE LOC = ‘MELB‘) 这两句效果一样
时间: 2024-10-14 09:41:17