网站评论区怎么做,做技术支持的网站有,中国网络优化推广,注册10万公司实缴多少钱原文#xff1a;http://blog.csdn.net/showshore/article/details/7263115 --------------------------------------------------------- 在做项目的过程中#xff0c;使用sql语句时#xff0c;很多时候会用到where或having。 看到国外一个论坛上有人提到两者性能比较的这个… 原文http://blog.csdn.net/showshore/article/details/7263115 --------------------------------------------------------- 在做项目的过程中使用sql语句时很多时候会用到where或having。 看到国外一个论坛上有人提到两者性能比较的这个问题时有人是这样回答的 The theory (by theory I mean SQL Standard) says that WHERE restricts the result set before returning rows and HAVING restricts the result set after bringing all the rows. So WHERE is faster. On SQL Standard compliant DBMSs in this regard, only use HAVING where you cannot put the condition on a WHERE (like computed columns in some RDBMSs.)
也就是说从理论上讲where是在查询前做条件限制having是在查询后的结果集上做条件限制。 查询前做限制的话返回的件数会少而在查询后的结果集上做限制的话之前的查询结果可能会很多这样就会影响性能。 所以一般是用wherehaving是在where不方便或者不能使用的情况下才使用。