星期二, 十月 17, 2006

plsql读书笔记5----子查询

1 ,匹配符
"=",">","<","<>",IN,ALL,ANY
其中,ALL,ANY必须跟单行比较符结合使用
2,多列子查询

3,相关子查询()??????????
EXISTS
SELECT ename ,job,sal,deptno FROM emp WHERE EXISTS
(SELECT 1 FROM dept WHERE dept.deptno = emp.deptno
AND dept.loc='NEW YORK');

4,FROM 中使用子查询(内嵌视图)
必须为子查询指定别名。
SELECT ename,job,sal FROM emp,
(SELECT deptno,avg(sal) avgsal FROM emp
GROUP BY deptno) dept
WHERE emp.deptno = dept.deptno AND sal>dept.avgsal;

没有评论: