Skip to content
Advertisement

Tag: having

What is the difference between HAVING and WHERE in SQL?

What is the difference between HAVING and WHERE in an SQL SELECT statement? EDIT: I have marked Steven’s answer as the correct one as it contained the key bit of information on the link: When GROUP BY is not used, HAVING behaves like a WHERE clause The situation I had seen the WHERE in did not have GROUP BY and

Can you use an alias in the WHERE clause in mysql?

I need to use an alias in the WHERE clause, but It keeps telling me that its an unknown column. Is there any way to get around this issue? I need to select records that have a rating higher than x. Rating is calculated as the following alias: Answer You could use a HAVING clause, which can see the aliases,

Advertisement