zoukankan      html  css  js  c++  java
  • sql基础知识回顾

    一:查询条件

       1:  >    <      =     >=     <=    !=   <>

     2:  and   or  

       3:  like 

       4:  in            not   in

       5:       between.......   and .....

       6:  is   null             is    not    null

       7:  any(任意一个)       all(所有

           这两个用于子查询

            例:select from student where 班级='01' and age > all (select age from student where 班级='02');   查询01班学生年龄大于02班所有的学生

                                      相当于:   select from student where 班级='01' and age > (select max(age) from student where 班级='02');

              select from student where 班级='01' and age > any (select age from student where 班级='02');   查询01班学生年龄大于02班任意学生

              相当于: select from student where 班级='01' and age > (select min(age) from student where 班级='02');

       8:  distinct    去重复

    二:排序

            order    by

             例如:select  deptno, sal, from emp order by deptno asc,sal desc;    

          其中:asc升序   desc降序

    三:分组

         group by(按什么分组)+  having(条件限制)

         例如:  select  * from  emp group by deptno having max(sal)>4000;

    四:计算函数

      1:  max     min

      2:avg(平均值) sum(合计)

      3:count(计算表中查询出来的行数)

    五:分页查询

      rownum(伪列)  返回标识行数据顺序的数字

      select * from (select ruwnum rm ,e.* from emp) where rm   between  1  and 15;

    6:decode函数

       DECODE(value,if1,then1,if2,then2,if3,then3,...,else),表示如果value等于if1时,DECODE函数的结果返回then1,...,如果不等于任何一个if值,则返回else。

      例如:select * from decode(job,'teacher',sal*1.2,'saleman',sal*1.5,sal) from emp;

     

        

      

      

       

  • 相关阅读:
    AngularJS Insert Update Delete Using PHP MySQL
    Simple task manager application using AngularJS PHP MySQL
    AngularJS MySQL and Bootstrap Shopping List Tutorial
    Starting out with Node.js and AngularJS
    AngularJS CRUD Example with PHP, MySQL and Material Design
    How to install KVM on Fedora 22
    Fake_AP模式下的Easy-Creds浅析
    河南公务员写古文辞职信
    AI
    政协委员:最大愿望是让小学生步行上学
  • 原文地址:https://www.cnblogs.com/jcfxl/p/8835487.html
Copyright © 2011-2022 走看看