zoukankan      html  css  js  c++  java
  • oracle查询sql语句

    一.模糊查询

    1.关键字   like

    2  通配符( —,%)

    一个—只能代表一个字符,

    %可以代替0到多个字符。

    select * from user where username='%a_';

    二.范围查询

    between ......and.....

    select * from   users  where salary  between  800 and  2000;

    查询结果包含800也包含2000.

    in/not in

    in后面是具体值,而不是范围

    三,对结果排序

    order by........DESC(降序)/ASC(升序)

    四,case........when语法的使用

    1.    case    column_name  when  value1   then  result1,..... .[else  result]  END

         例子:select username,case username  when 'aaa' then '计算机部门'

                    when 'bbb' then'市场部门'   else '其他部门'  end  as'其他部门'

                    as'部门' from users

    2.   case     when     column1=value1   then  result1,..... .[else  result]  END

                 

       例子:select username,case  when username=' aaa' then '计算机部门'

                    when username='bbb' then '市场部门'   else '其他部门'  end  as'其他部门'

                    as'部门' from users

    五,decode函数的使用

    decode(column_name,value1,result1,...........defaultvalue)

    select  username,decore(username,'aaa','计算机部门',‘bbb’,'市场部门',‘其他’)as 部门 from users

  • 相关阅读:
    《分布式系统关注点——数据一致性(上篇)》阅读笔记
    2.23寒假学习记录
    2.22寒假学习记录
    2.21寒假学习记录
    2.20寒假学习记录
    2.19寒假学习记录
    2.18寒假学习记录
    2.17寒假学习记录
    2.17周一毕设改进计划
    2.16寒假学习记录
  • 原文地址:https://www.cnblogs.com/libaowen609/p/12819678.html
Copyright © 2011-2022 走看看