mysql查询时的书写顺序:
select...from...where...group by...having...order by...
mysql的执行顺序:
from...where...group by...having...select...order by...
from:需要从哪个数据表检索数据
where:过滤表中数据的条件
group by:如何将上面过滤出的数据分组
例句:select cid,count(*) from product group by cid //注释:cid为product表的外键,可以模拟查询统计每个分类产品的数量
having:对上面已经分组的数据进行过滤的条件
例句:select cid,avg(price) from product group by cid having avg(price)>60