zoukankan      html  css  js  c++  java
  • sqlplus 条件查询

    条件查询

    where字句用来过滤查询的数据,它对字面量大小写是敏感

    语法:
    select 列名1,列名2...
    from 表名
    where 筛选的条件;

    1.比较运算符
    >,<,=,<=,>=,!=(^=,<>)


    --查询在41部门的员工名字,工资
    select
    first_name,salary
    from

    s_emp

    where
    dept_id=41
    ;

    --查出工资高于1500的员工的信息;
    select * from s_emp where salary>1500;

    --找出工资大于1200的员工的全名、工资、职位
    select first_name||' '||last_name 全名,salary 工资,title 职位
    from s_emp
    where salary >1200;


    -----------------------------------------------------------------------

    2.逻辑运算符
    and,or

    --查出41部门中工资高于1200的员工名字,工资;
    select first_name, salary ,dept_id
    from s_emp
    where dept_id = 41 and salary > 1200;


    --查出41,50,42部门的员工名字,薪水;
    select first_name,salary from s_emp where dept_id=41 or dept_id=42 or dept_id=50;

    ----------------------------------------------------------------------

    3.其他运算符
    in() 取多个数值,多个值使用逗号隔开
    例:
    deot_id in(41,42,50)相当于dept_id=41 or dept_id=42 or dept_id=50;

    not in()

    between 2 and 6 在指定的范围之内,是全闭空间;相当于>=2 and <=6
    dept_id>2 and dept_id<6 非全闭空间

    is null
    is not null

    模糊查询:like
    通配符:rose
    _通配任意单个字符
    %通配任意多个字符

  • 相关阅读:
    SharePoint 2013 工作流之使用Visio设计篇
    SharePoint 2013 工作流之Visual Studio开发示例篇
    Ajax
    jq判断上下滚动
    元素(绝对定位)水平垂直居中
    css3动画:animation
    自定义button上传按钮
    Json
    页面滚动到顶部
    HDU 4358 Boring counting dfs序+莫队算法
  • 原文地址:https://www.cnblogs.com/zhang12354/p/7767395.html
Copyright © 2011-2022 走看看