darui

MySQL中 进行排序的方式:

Select * from 表名 [where 条件 order by  字段名(默认的是ASC升序排列)]

ASC是升序排列,DESC用来指定降序排列

Oracle中子查询:

Select * from 表名 where 条件 (select * from 表名 where 条件)

 

 

实例:

in: select * from emp where deptno in (select deptno from dept where loc = \'DALLAS\' or loc = \'BOSTOM\');
all: select * from emp where sal > all(select sal from emp where ename = \'JAMES\' or ename = \'FORD\');
any: select * from emp where sal > any(select sal from emp where ename = \'JAMES\' or ename = \'FORD\');
exists: select * from emp where exists (select sal from emp where ename = \'JAMES\' or ename = \'FORD\');

 

union操作用于计算两个结果集的并集,它在取并集时会自动去掉结果集的重复行。
select * from emp where sal <= 1600 union select * from emp where sal >= 1500;
intersect操作于计算两个结果集的交集
select * from emp where sal <= 1600 intersect select * from emp where sal >= 1500;
minus操作用于计算两个结果集的差集(只返回在第一个结果集中存在,但在第二个集中不存在的数据)
select * from emp where sal <= 1600 minus select * from emp where sal >= 1500;

其他方法:

 

 

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2021-11-29
  • 2021-07-11
  • 2021-11-18
猜你喜欢
  • 2021-12-16
  • 2021-11-12
  • 2022-12-23
  • 2021-10-02
  • 2021-09-26
  • 2021-04-26
  • 2022-12-23
相关资源
相似解决方案