I have two queries:
SELECT `u`.*, `ic`.* FROM `users` `u`,
JOIN `invitation_codes` `ic`
ON `ic`.user_id = `u`.id
WHERE `u`.`mail` = :mail AND `is_deleted` = 0;
AND
SELECT * FROM `users`,
(SELECT `level` FROM `point_thresholds` WHERE :points BETWEEN `low_threshold` AND `top_threshold`) AS level,
(SELECT `level_name` FROM `point_thresholds` WHERE :points BETWEEN `low_threshold` AND `top_threshold`) AS level_name
WHERE `mail` = :mail AND `is_deleted` = 0;
Now I am trying to combine this queries into one:
SELECT `u`.*, `ic`.* FROM `users` `u`,
(SELECT `level` FROM `point_thresholds` WHERE :points BETWEEN `low_threshold` AND `top_threshold`) AS level,
(SELECT `level_name` FROM `point_thresholds` WHERE :points BETWEEN `low_threshold` AND `top_threshold`) AS level_name
JOIN `invitation_codes` `ic`
ON `ic`.`user_id` = `u`.`id`
WHERE `u`.`mail` = :mail AND `is_deleted` = 0;
Unfortunately he gets the error #1054 - Unknown column 'u.id' in 'on clause' and I have no idea why, theoretically everything looks quite OK. Someone would be able to and would like to suggest what I am doing wrong?