码迷,mamicode.com
首页 > 其他好文 > 详细

select 选项的子句

时间:2016-11-27 07:14:54      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:下标   length   sum   span   条件语句   desc   平均值   off   having   

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;

 

select 选项的子句

标签:下标   length   sum   span   条件语句   desc   平均值   off   having   

原文地址:http://www.cnblogs.com/zgh0715/p/6105698.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!