sqlplus 条件查询

条件查询

where字句用来过滤查询的数据,它对字面量大小写是敏感

语法:
select 列名1,列名2...
from 表名
where 筛选的条件;

1.比较运算符
>,<,=,<=,>=,!=(^=,<>)


--查询在41部门的员工名字,工资
select
first_name,salary
from

s_emp

where
dept_id=41
;

 

--查出工资高于1500的员工的信息;
select * from s_emp where salary>1500;

--找出工资大于1200的员工的全名、工资、职位
select first_name||' '||last_name 全名,salary 工资,title 职位
from s_emp
where salary >1200;


-----------------------------------------------------------------------

2.逻辑运算符
and,or

--查出41部门中工资高于1200的员工名字,工资;
select first_name, salary ,dept_id
from s_emp
where dept_id = 41 and salary > 1200;


--查出41,50,42部门的员工名字,薪水;
select first_name,salary from s_emp where dept_id=41 or dept_id=42 or dept_id=50;

 

----------------------------------------------------------------------

3.其他运算符
in() 取多个数值,多个值使用逗号隔开
例:
deot_id in(41,42,50)相当于dept_id=41 or dept_id=42 or dept_id=50;

not in()

between 2 and 6 在指定的范围之内,是全闭空间;相当于>=2 and <=6
dept_id>2 and dept_id<6 非全闭空间

is null
is not null

模糊查询:like
通配符:rose
_通配任意单个字符
%通配任意多个字符

转载于:https://www.cnblogs.com/zhang12354/p/7767395.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值