Oracle条件查询

条件查询 {where后面的写法}
关系运算符: > < = <= >= != <>
逻辑运算符: and or not
其他运算符: like 模糊查询
	    in(set) 在某个区间内
	    between .. and.. 在某个区间内
            is not 判断为空  
            is not null 判断不为空

----查询每月能得到奖金的员工信息
select * from emp;
select * from emp where comm is not null;


----查询工资在1500-3000之间的员工信息
select * from emp where sal between 1500 and 3000;

select * from emp where sal >= 1500 and sal <= 3000;

----查询名字在某个范围内的员工信息('JONES','SCOTT','FORD')
select * emp where ename in ('JONES','SCOTT','FORD');



模糊查询:like
	% 匹配多个字符
	_匹配单个字符
	如果有特殊字符需要使用escape转义
-----查询员工姓名第三个名字是O的员工信息
select * from emp where ename like '__O%';

----查询员工姓名中,包含%的员工信息
update emp set ename = 'TUR%NER' where ename = 'TURNER';

select * from emp where ename like '%\%%' escape '\';


排序:order by
升序:asc ascend
降序:desc descend

排序注意null问题,nulls 默认是first  需要的话可以改为last
如果同时排列多列,,中间用,隔开

----查询员工信息,按照奖金由高到低排序
select * from emp order by comm desc nulls last;

----查询部门编号和工资,按照部门升序排序,工资降序排序
select deptno,sal from emp order by deptno asc, sal desc;

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值