I have a query like this:
SELECT User.id, 10*10 as distance FROM USERS INNER JOIN ( SELECT Location.user_id, min(10 * 10) as mindistance FROM Location GROUP BY Location.user_id ) L ON Users.id = Location.user_id AND distance = L.mindistance
If I leave it as it is, I keep getting:
Unknown column 'distance' in 'on clause'
But if I put User.distance instead of distance, I get:
MySQL syntax error near....
Can I use the βthis wayβ alias in the computed field? 10 * 10 is just a simple placeholder, because the calculation is much more complicated.
source share