EXISTS是判断是否存在,和in类似,但效率要比in高
SELECT*FROMEMP(基础表)WHEREEMPNO>0ANDEXISTS(SELECT‘X'FROMDEPTWHEREDEPT.DEPTNO=EMP.DEPTNOA等争间NDLOC=‘MELB')
SELECT*FROMEMP(基础表)WHEREEMPNO>0ANDDEPT微慢坐练旧字素NOIN(SELECTDEPTNOFROMDEPTWHERELOC=‘MELB')
这两句效果一样
EXISTS是判断是否存在,和in类似,但效率要比in高
SELECT*FROMEMP(基础表)WHEREEMPNO>0ANDEXISTS(SELECT‘X'FROMDEPTWHEREDEPT.DEPTNO=EMP.DEPTNOA等争间NDLOC=‘MELB')
SELECT*FROMEMP(基础表)WHEREEMPNO>0ANDDEPT微慢坐练旧字素NOIN(SELECTDEPTNOFROMDEPTWHERELOC=‘MELB')
这两句效果一样
扫一扫,手机浏览