• Oracle 条件查询 模糊查询


    示例:

    1)      查询出工资高于3000的员工信息

    select  *

    froms_emp e

    where e.salary>3000;

    2)      查询出名为Carmen的员工所有信息

    select * from s_emp e

    wheree.first_name ='Carmen';

    【oracle sql  关键字,表名,列名等不区分大小写, 记录中的值大小写敏感】

    3)      查询出没有绩效的员工信息

    select * from s_emp e

    where  e.commission_pct is not null;

    4)      查询出工资在1200-3000 之间的员工的姓名,部门编号与薪资

    selecte.first_name,e.dept_id,e.salary

    froms_emp e

    wheree.salary>=1200 and e.salary<=3000;

    selecte.first_name , e.dept_id,e.salary

    froms_emp e

    wheree.salary between 1200 and 3000;

    • like : 模糊查询

    通配符 % 与 _

    % :表示任意多个字符

    _ : 表示任意一个字符

    1)      查询出员工姓名中包含字母为'a'的员工的信息

    select * from s_emp e

    where e.first_name like '%a%'

    2)      查询出员工姓名中第一个字母为'S'的员工的姓名

    select * from s_emp e

    wheree.first_namelike'S%'

    3)      查询出员工姓名中包含'a'和'f'的员工的信息

    select * from s_emp e

    wheree.first_name like '%a%' and e.first_name like '%f%';

    4)      查询出员工姓名中倒数第三个字母为'i'的员工的信息       

    select * from s_emp e

    wheree.first_name like '%i__ '

    5)      查询出在31,41部门的所有员工的姓名,部门编号与职位

    selecte.first_name,e.dept_id,e.title from s_emp e

    wheree.dept_id = 31 or e.dept_id = 41;

    selecte.first_name,e.dept_id,e.title from s_emp e

    where e.dept_id in (31,41);

    【in(31,41)相当于:dept_id=31 or dept_id=41】

    6)      找出既不是销售,也不是办事员的员工

    select * from s_emp

    where title != ‘Sales Representative’and title != ‘Stock Clerk’;

    select * from s_emp

    where title not in(‘Sales Representative’,’Stock Clerk’);

    【not in(‘Sales Representative’,’Stock Clerk’)相当于】

    title != ‘Sales Representative’and title != ‘Stock Clerk’

    • 【dual 表: oracle中虚拟表,保证sql语句完整。】

    【获得 4+30 的值】

    select (4+30) from dual;

    【获得当前系统时间】

    Select sysdate from dual;

    【 获取 ‘hello’】

    select  'hello'  from dual;

  • 相关阅读:
    SSL证书安装指引
    SSL证书绑定成功
    我是如何将网站全站启用Https的?记录博客安装配置SSL证书全过程
    _INT_SIZEOF 规格严格
    Java: Multidimensional array vs. Onedimensional 规格严格
    Fix JDK TImer 规格严格
    Ecpilse debug视图 规格严格
    PE 分析 规格严格
    VC Unicode 规格严格
    Object Pool 规格严格
  • 原文地址:https://www.cnblogs.com/ty-v/p/7845990.html
Copyright © 2020-2023  润新知