Home > Database > Mysql Tutorial > 7月2日总结,mysql 之select_MySQL

7月2日总结,mysql 之select_MySQL

WBOY
Release: 2016-05-31 08:49:28
Original
888 people have browsed it

函数:

MAX(); 返回该字段的最大值  

MIN();返回该字段的最小值

COUNT(); 

返回该数据库的行数切非NULL的值,count(*)返回该数据库里的行数,count(name),如果是字段值,若该字段的值有NULL的情况,则该不计入总数。

AVG();返回该字段的平均值

SUM();返回该字段的总和

GROUP BY: 对所在字段进行分组。

若数据库里有张三,李四,王五,张三,赵六,李四

select * from name where 1 group by name, 该字段就是输出后,张三,李四,王五,赵六.(李四和张三有多条,也各显示纪录)

ORDER BY: 对字段进行升序/降序 进行排列;

DESC 降序          ASC 升序

     select * from goods ordery by  id desc  对id列进行降序排序

LIMIT限制条目  LIMIT[Offset,] N     offset是偏移量(可选项) N取出的条目

   select * from goods order by id desc limit 0,3 对id进行从大到小排序,只显示前三条纪录。

select * from goods order by id desc limit 2,3 对id进行从大到小排序,只显示3,4,5条纪录;

   

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template