zoukankan      html  css  js  c++  java
  • 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;

  • 相关阅读:
    iOS- 优化与封装 APP音效的播放
    iOS- iPhone App 如何运营?
    iOS- 封装单例宏
    iOS- 详解文本属性Attributes
    iOS- 如何将应用集成发短信、发邮件、打电话
    iOS- <项目笔记> UIApplication常见属性与方法总结
    iOS- <项目笔记>iOS6 & iOS7屏幕图片适配
    iOS- <项目笔记>项目配置常见文件
    iOS- <项目笔记>UI控件常见属性总结
    iOS- UIPickerView餐厅点餐系统
  • 原文地址:https://www.cnblogs.com/ty-v/p/7845990.html
Copyright © 2011-2022 走看看