Oracle数据库(where语句和列表达式)

来源:互联网 发布:淘宝达人怎么修改昵称 编辑:程序博客网 时间:2024/04/30 03:37
1.Where语句
关系运算:>、<、=、!=、<>、>=、<=
逻辑运算符:not、and、or
is null:是否为空
between:在某两个值之间
in:一系列值中
like:相似值的比较
exits:是否存在符号条件的数据
unique:是否唯一
all/any:一组数据的所有/其中的任何一个
%: 匹配符,匹配0个、一个或多个任意字符的
||:字符串拼接 例如:'基本工资:'|| sal
字段别名:
例子:
-- 查询奖金是空的的所有雇员
select * FROM emp where comm is null;
-- 查询工资1500-3000的员工
select * from emp where sal between 1500 and 3000;
select * from emp where sal >=1500 and sal<=3000;
--查询所有办事人员,销售人员,管理者
selEct * from emp where job in('CLERK','SALESMAN','MANAGER');
select * from emp where job='CLERK' OR JOB='SALESMAN' OR JOB='MANAGER';
-- 匹配符,匹配0个、一个或多个任意字符的
select * from emp where ename like 'M%';

select * from emp where ename like '%S';

select * from emp where ename like '%A%';
2.列表达式
开始:case
结束:end
当..条件:when
就:then
否则:else
例子:
--显示员工各项工资明细个各项工资总和
SELECT '基本工资:'||sal sal,'奖金:'|| comm comm ,
case
when comm is not null
then sal+comm
else sal
end total
from emp;
原创粉丝点击