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';
转自:https://www.cnblogs.com/superdrew/p/8053863.html (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|