zoukankan      html  css  js  c++  java
  • Oracle条件查询语句-where

    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'; 
  • 相关阅读:
    细心也是一种态度
    EDM数据访问的三种方式
    如何快速提交网站备案 ICP备案
    c# winform 关于给静态全局变量赋值的问题
    c#DIY随机数类winform 2010
    手把手教你如何用IIS搭建手机WAP网站(图文)
    admin密码对应的MD5值,16位和32位,admin解密自己留着方便.
    C#实现MD5加密,winform c#2005
    最全的c#日期函数 winform
    如何解决因网站备案号没下来而网站被迫关闭的办法
  • 原文地址:https://www.cnblogs.com/superdrew/p/8053863.html
Copyright © 2011-2022 走看看