13719654321 发表于 2018-9-7 08:32:44

Oracle-子查询

  一、WHERE条件中的子查询
  1. 比black工资高的雇员有哪些?
  select ename
  from emp
  where sal>(select sal from emp where ename='BLAKE');
  2. 高于30部门最高工资的雇员有哪些?
  select ename,sal
  from emp
  where sal>(select max(sal) from emp where deptno=30);
  select ename,sal
  from emp
  where sal > all (select sal from emp where deptno=10);   --任何
  3. 当all后面接子查询的时候
  "x = ALL (...)": The value must match all the values in the list to evaluate to TRUE.所有值都要匹配
  "x != ALL (...)": The value must not match any values in the list to evaluate to TRUE.至少有一个值不匹配
  "x > ALL (...)": The value must be greater than the biggest value in the list to evaluate to TRUE.大于最大的值
  "x < ALL (...)": The value must be smaller than the smallest value in the list to evaluate to TRUE.小于最小的值
  "x >= ALL (...)": The value must be greater than or equal to the biggest value in the list to evaluate to TRUE.大于等于最大的值
  "xANY (...)": The value must be greater than the smallest value in the list to evaluate to TRUE.大于最小值
  "x < ANY (...)": The value must be smaller than the biggest value in the list to evaluate to TRUE.小于最大值
  "x >= ANY (...)": The value must be greater than or equal to the smallest value in the list to evaluate to TRUE.大于等于最小值
  "x
页: [1]
查看完整版本: Oracle-子查询