本文介绍了SQL中的WHERE和HAVING之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我曾在 WHERE
和 HAVING
上看过各种讨论。我仍然有一个问题: HAVING
只在考虑聚合时才使用,或者可以用更一般的术语使用:每当您在查询中创建或替换字段时?
我知道应该尽可能地使用 WHERE
。
解决方案
HAVING
指定搜索 SELECT
语句中使用的内容。
换句话说。
HAVING
适用于团体。
WHERE
适用于行。
I have seen various discussions on WHERE
and HAVING
. I still have a question: is HAVING
used only when considering aggregates, or can it be used in more general terms: whenever you have created or aliased a field in your query?I know that WHERE
should always be used when possible.
解决方案
HAVING
specifies a search for something used in the SELECT
statement.
In other words.
HAVING
applies to groups.
WHERE
applies to rows.
这篇关于SQL中的WHERE和HAVING之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!