Why do you need to place columns you create yourself (for example select 1 as "number") after HAVING and not WHERE in MySQL?
And are there any downsides instead of doing WHERE 1 (writing the whole definition instead of a column name)?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
WHEREis applied beforeGROUP BY,HAVINGis applied after (and can filter on aggregates).In general, you can reference aliases in neither of these clauses, but
MySQLallows referencingSELECTlevel aliases inGROUP BY,ORDER BYandHAVING.If your calculated expression does not contain any aggregates, putting it into the
WHEREclause will most probably be more efficient.