SQL中的WHERE和HAVING之间的区别 [英] Difference between WHERE and HAVING in SQL

查看:238
本文介绍了SQL中的WHERE和HAVING之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


我曾在 WHERE HAVING 上看过各种讨论。我仍然有一个问题: HAVING 只在考虑聚合时才使用,或者可以用更一般的术语使用:每当您在查询中创建或替换字段时?
我知道应该尽可能地使用 WHERE

HAVING 指定搜索 SELECT 语句中使用的内容。



换句话说。



HAVING 适用于团体。

WHERE 适用于行。


Possible Duplicate:
SQL: What's the difference between HAVING and 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之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆