• 数据库相关--mysql中的单表查询


    一、完整的单表查询语句

    select [distinct] *|字段1,字段2, ....

      from 表名

      [where 条件1]

      [group by 字段名 [having 条件2] ]

      [order by 字段名 [asc|desc] ]

      [limit [star],count ]

    二、执行顺序(由上而下)

    from 表名

    where 条件

    group by

    select [distinct] *|字段

    having 条件

    order by

    limit star,count

    三、运算符

    比较运算符:=   <>  !=  <   <=  >  >= 

    逻辑运算符:and  or  not

    优先级:

      1.小括号,not,比较运算符,逻辑运算符;

      2.and,or,如需先进行or,则使用();

    四、带关键字的查询

    where [not] in(元素1,元素2,....)  非连续的范围查询

    where [not] between 值1 and 值2    连续的范围查询

    where 字段名 is [not] null   空值查询

    where 字段名 [not] like "匹配字符串"    模糊查询,其中可使用"%"进行0-多个匹配;使用"_"进行单个字符匹配

    五、聚合函数

    count()  计数

    sum()  求和

    avg()  求平均

    max()  求最大

    min()  求最小

    使用: select 函数(字段) from 表名;

     后续更新......

  • 相关阅读:
    Node.js基础学习一之Get请求
    Node.js学习准备篇
    如何在eclipse添加SVN菜单
    Java泛型的好处
    mybatis多数据源配置
    Python map() 函数
    python split()使用方法
    pythom os 模块
    深浅copy
    小数据池
  • 原文地址:https://www.cnblogs.com/wendaobiancheng/p/9075338.html
Copyright © 2020-2023  润新知