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

select查询的执行顺序

时间:2015-04-26 10:58:31      阅读:100      评论:0      收藏:0      [点我收藏+]

标签:select

一些不知道为什么执行出错的SQl语句,往往是因为你不了解他的执行顺序。

Select distinct top n [percent] 列名

from 表名

where 条件

group by ... having ...

order by ... asc/desc


执行顺序

1>...from 表

2>...where 条件

3>...group by    列

4>...having 筛选条件

5>...Select >选择列 >distinct

6>...order by 列

7>...Top(最后计算)

select查询的执行顺序

标签:select

原文地址:http://blog.csdn.net/langji1234/article/details/45285855

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