I want to both fetch and use in a where clause the value returned from a sub-select in MySQL. Is this possible? It seems unecessary to write the sub-query out twice - however if I need to, will MySQL be clever enough to only run it one?
I have tried the following which does not work:
SELECT
(SELECT 1 FROM table WHERE somereallycomplicatedclause = 'something')
AS subselectresult
FROM content WHERE subselectresult = 1
This generates this error:
#1054 - Unknown column 'subselectresult' in 'where clause'
Thanks