For some reason, this doesn’t work:
select substring(rating, instr(rating,',') +1, +2) as val
from users where val = '15';
It gives this error:
ERROR 1054 (42S22): Unknown column ‘val’ in ‘where clause’
How do I do it then?
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.
First, you cannot use
ALIASon theWHEREclause. You shoul be using the column,The reason is as follows: the order of operation is SQL,
the
ALIAStakes place on theSELECTclause which is before theWHEREclause.if you really want to use the alias, wrap it in a subquery,