I have the following query:
SELECT * FROM questions
LEFT JOIN answers ON (questions.id = answers.id AND (connections.username = answers.username OR connections.username = 'bob' OR answers.username IS NULL))
LEFT JOIN connections ON connections.username1 = 'mikha' AND
(connections.username2 = answers.username)
LEFT JOIN answers answers2 ON (questions.id = answers2.id)
WHERE (answers.id <> answers2.id)
I get the following error:
`Unknown connections.username in ON clause`
I define some conditions in the first join and want to get the rest that don't match these conditions. That's why I use this part answers.id AND answers2.id
. To get IDs that don't match the conditions in the first left join.
Thanks