zoukankan      html  css  js  c++  java
  • select 选项的子句

    select 选项 :

    关键字 all :全部(默认值)distinct:去掉重复的查询结果。语法:select all * from 表名;

    别名:

    关键字:as 语法:select * from 表名 as 别名;

    虚拟表:名称dual 可以没有表名可当计算器使用。

    子句:where group by having order by limit

    where子句:

    语法:select * from 表名 where 条件语句;

    group by 子句:

    分组查询语句 关键字 sum()总和 max()最大数 min()最小数 avg()平均值 count(*)总个数

    语法:select 字段名, sum(字段名)from 表名 group by 字段名;

    回溯统计:

    直接在语法后面加with rollup关键字就可以查询数据表的【asc升序(默认)/desc降序】

    having子句:

    跟where的功能一样,有以下的区别:

    where子句的后面不能使用统计函数,而having子句可以,因为只有在内存中的数据才可以进行运算统计。

    order by子句:

    对数据表进行排序,语法:select * from 表名order by 字段名 asc/desc;

    limit子句:

    限制查询数据的输出,limit offset,(可省略)length

    语法:select * from 表名 limit 3(可以当成是数据表的下标),5(代表输出的条数);

    分页:公式

    $a=表示多少页 $b=表示的长度

    limit($a-1)*$b;

  • 相关阅读:
    Java_多线程入门
    JAVA多线程基础(一)
    多线程1
    1.优化MySQL数据库
    廖胤松
    Mybatais
    Spring Boot入门
    MySQL的安装步骤详解
    MySQL入门
    WEB测试方法
  • 原文地址:https://www.cnblogs.com/zgh0715/p/6105698.html
Copyright © 2011-2022 走看看