oracle的条件查询语句怎么写,Oracle条件查询语句-where

本文介绍了SQL查询中的WHERE子句,展示了如何根据部门编号、工资、员工编号、入职日期、姓名等条件筛选员工信息。讨论了单引号的使用、日期格式、比较运算符(如>、<、BETWEEN、IN)以及不等于操作。还提到了LIKE通配符用于模糊匹配,以及IS NULL和NOT IS NULL判断字段是否为空。
摘要由CSDN通过智能技术生成

where语句的查询

--where子句

--查询部门编号是10的所有的员工

select * from emp where deptno = 10;

--查询部门中工资是3000的员工

select * from emp where sal = 3000;

--找到部门中编号是 7788的员工

select * from emp where empno = 7788;

--查询姓名为SCOTT的员工所有信息

--在使用where 查询条件,字符串是单引号而且区分大小写

select * from emp WHERE ename = 'SCOTT';

--查询所有在日期是1981年5月1日入职的员工信息

--select from emp where hiredate = '1981-5-1';

--日期默认格式是 DD-MON-YYYY 查询条件按照日期来,日期也要加单引号

select from emp where hiredate = '1/5月/1981';

--查询工资大于3000的员工

select * from emp where sal>=3000; ---注意:sal=>3000 是错误的!数据库将不认识此符号!

--查询工资范围在1500-3000的员工所有信息

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

-- between..and...表示介于 两个值之间,包涵边界值

select from emp where sal between 1500 and 3000;

--查询姓名是KING和SCOTT的详细信息

select from emp where ename = 'KING' or ename ='SCOTT';

--IN 表示出现在集合中的记录

select from emp where ename in ('KING','SCOTT');

--查询工资不等于3000的员工信息

select from emp where sal <> 3000; --method1

select from emp where sal !=3000; --method2

select * from emp where not sal = 3000; --method3 取反运算

--查询所有没有提成的员工的信息

-- is null 表示某个字段为空 不为空 is not null

select from emp where comm is not null;

-- 取反的意思 where not comm is null

select from emp where not comm is null;

-- not 也可以代表取反的意思

select * from emp where ename not in ('KING','SCOTT');

--查询所有姓名以s开头的员工信息

-- 使用 like 和 通配符

-- 两个通配符 %代表0个或者多个字符 _一个字符

select from emp where ename like '%S'; ---字符(或是' ')里面严格区分大小写。建议全部大写书写语句!

--查询名字中带有0的

select from emp where ename like '%O%';

--查询第二个字母是L的员工的所有信息

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

--查询员工姓名中带有的所有的信息

--ESCAPE ‘’ 相当于自己定义一个转义符

select * from emp where ename like '%a%' ESCAPE 'a';

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值