mysql数据库查询

聚合查询:

sum() max min avg count(*)

select max(aaa) from yyy

select count(bbb) from yyy  //统计某列数据条数

select count(*) from yyy  //统计表数据条数

分页查询:

limt 起始行(从0开始),查询几行,

select * from yyy limit 0,2   

select * from yyy limit 4,2   

查询排序: 

order by desc递减,asc递增

select aaa from yyy order by bbb desc,ccc asc

分组查询:

group by ccc

select ccc,count(*) from yyy group by ccc

分组查询后筛选:

select ccc,count(*) from yyy group by ccc having count(*)>2

原文地址:https://www.cnblogs.com/god3064371/p/11444152.html