hi
i am trying to run a query like this
SELECT a, b , c, (SELECT INNULL(x,y)) as mycol WHERE mycol < 400 ;
BUt it gives the error
#1054 - Unknown column 'mycol' in 'where clause'
What would be the right way to do this?
Thanks.
hi
i am trying to run a query like this
SELECT a, b , c, (SELECT INNULL(x,y)) as mycol WHERE mycol < 400 ;
BUt it gives the error
#1054 - Unknown column 'mycol' in 'where clause'
What would be the right way to do this?
Thanks.
It's so in MS SQL, so I assume, that the same problem is in MySQL.
Try to change WHERE to HAVING. WHERE clause doesn't see your renamed columns.
HAVING is working the same way as WHERE, like (mycol < 400 AND a > 5).
GROUP BY should be before HAVING.
Check the examples in the link.