zoukankan      html  css  js  c++  java
  • 数据库操作运算符

    1、> 

    2、<

    3、>=

    4、<=

    5、<>:不等于

    6、between A and B:查询位于A和B区间(闭区间)的数据且必须遵循左小右大的原则,除了可以使用在数据方面,还可以使用在字符方面(但是左闭右开)

    7、is null:查看某个字段为null的数据项,select * from tablename where bonus  is null ,不能写成select * from tablename where bonus  =  null 

    8、and / or:两者联用时,and的优先级大于or优先级,or语句一般要括起来,括起来的优先级更高最先执行

     

    9、in / not in

     

     

     

    10、like:模糊查询,必须掌握的两种符号 " % "  和 " _ " ,''%":代表多个字符,"_":代表一个字符。

      

     

     

     

     11、排序(升序/降序):默认是升序,asc:升序 / desc:降序

      

     

     

     

    12、分组函数:count,sum,avg,max,min,分组函数会自动忽略null,即不会统计为null的数据项.注意:不管任何数据库,只要有null进行算数运算,就会产生null的结果值

      select count(*)  from tablename ;

      select sum(salary)  from tablename ;

      select max(age)  from tablename ;

      select avg(salary) from tablename;

    count(*):对数据条数进行统计,包含null。

    count(字段名):对某个字段所含的数据项进行统计,不包括null。

     

    13、group by 和 having

    group by:按照某个字段或者某些字段进行分组

    having:对分组后的数据再进行筛选

    注意:where 后面不能直接跟分组函数,会报错

     

     

    (1) 找出每种职业中年纪最大的人:SELECT id,name,sex,MAX(age),career FROM test1 GROUP BY career;

     

     

    (2) having 和 group by是搭档,having离开group不能单独使用。

     

     

     

    14、distinct:去重关键字,且必须写在查询字段的前面

         

  • 相关阅读:
    小程序中template的用法
    小程序弹窗的几种形式
    js怎样截取以'-'分割的字符串
    js怎样截取字符串后几位以及截取字符串前几位
    局域网聊天软件项目小结(1)
    IPAddress类
    Combobox 成员添加
    tcpclient 类
    console.read()读入的内容
    技术带来的进步与退步---一点点反思
  • 原文地址:https://www.cnblogs.com/ibear/p/12108456.html
Copyright © 2011-2022 走看看