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

  • 相关阅读:
    mybatis入门
    Golang学习笔记——Slice
    struts2文件上传问题
    分页查询的具体实现
    ajax发送异步请求——GET方式
    Golang学习笔记——array
    关于Spring出现"COMMIT/AUTO or remove 'readOnly' marker from transaction definition."的解决办法
    Golang学习笔记——control_structure
    SSH框架整合过程
    Golang学习笔记——variable
  • 原文地址:https://www.cnblogs.com/libaowen609/p/12819678.html
Copyright © 2011-2022 走看看