Oracle学习4:distinct、between and、in、like详解

1.distinct

distinct A,B 用于取出不同的组合记录。
取出不同的雇员

select distinct employee from test_ljb;

取出雇员和薪水的不同组合。

select distinct t.employee, t.salary from test_ljb t;

2.between a and b [a,b]

等价于数学中的[a,b],闭区间,包括边界

取出薪水在1000-1500的薪水。

select t.salary from test_ljb t where 1=1 and t.salary between 1000 and 1500;

等价于

select t.salary from test_ljb t where 1=1 and t.salary >=1000 and t.salary <=1500; 

3.in(’ ‘,’ ‘)

选取处于in表达式里的数据。

select t.employee, t.salary from test_ljb t where t.salary in (1000,1500,2000);

4.is(is not)

select t.* from test_ljb t where t.bonus is null;
select t.* from test_ljb t where t.bonus is not null;

5.like及通配符、转移字符

%:任意多个任意字符 (>=0)
_:一个任意字符 (= 1)

选取名字中包含a的雇员

select t.employee from test_ljb t where t.employee like '%a%';

选取第二个字母为a的雇员

select t.employee from test_ljb t where t.employee like '_a%';

选取姓名中包含’%’的雇员

select t.employee from test_ljb t where t.employee like '%\%%' escape '\';

escape用于指定转义字符,当然我们可以指定其他的转移字符。如:

select t.employee from test_ljb t where t.employee like '%*%%' escape '*';
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值