what's the difference between WHERE and HAVING

前端 未结 5 832
孤街浪徒
孤街浪徒 2021-02-07 02:31

It looks like both WHERE and HAVING help filter rows. I wonder if, instead of having to HAVING, I can use WHERE ... AND.

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-07 03:13

    There are some subtleties and intricacies, but quick description is a comparison: HAVING is to GROUP BY as WHERE is to SELECT.

    In other words, if you think of HAVING as a WHERE clause that gets applied after the GROUP BY clause, things start to make sense.

提交回复
热议问题