I have a query like the below:
SELECT *, (
SELECT `name` FROM `users` WHERE `users`.`id`=``.``
) AS `fullName` FROM `listings` WHERE `fullName` LIKE '%praveen%';
But when I execute the above query, I am getting this error:
#1054 - Unknown column 'fullName' in 'where clause'
I know that this bug has been documented. I am not sure what's the workaround for this other than doing something like:
SELECT *, (
SELECT `name` FROM `users` WHERE `users`.`id`=`listings`.`user`
) FROM `listings` WHERE (SELECT `name` FROM `users` WHERE users`.`id`=`listings`.`user`) LIKE '%praveen%';
Is there any other way I can do this other than creating a view, or using a query like the above? I have tried referring other questions:
- Unknown column in subquery where clause
- Unknown column when using subquery result column in WHERE clause
- Unknown Column In Where Clause
- Unknown column '' in 'where clause'
- unknown column in where clause
I couldn't find a better solution. What's the best can I do in this case? Thanks in advance.