首页 > 数据库技术 > 详细

标准sql执行顺序

时间:2017-11-04 17:38:38      阅读:246      评论:0      收藏:0      [点我收藏+]

 

  1:form 组装来自不同表的数据,如 form user或者,form user as u join goodsOrder as r on u.id= r.userid

  2:where 过滤符合查询条件的数据,如:id>1000

  3:group by 将查询数据进行分组

  4:使用sum等聚合函数进行计算。

  5:使用having 进行筛选分组。

  6:执行select语种

  7:执行排序语句

  如:select count(gid),gname from shopping_goods where gcid=1 group by gname having count(gid)>1 order by count(gid) desc

  1:首页查询shopping_goods 表,得到表中的数据

  2:执行where,过滤出gcid=1的商品。

  3:对gname进行分组。

  4:使用聚合函数count(),计算出商品类型为1,不同商品名称的数量.

  5:使用having,过滤出类型为1,商品统计数量大于1的商品

  6:执行select语句

  7:执行order by ,按照商品数量降序排列。

标准sql执行顺序

原文:http://www.cnblogs.com/wdx8927304/p/7783725.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!