我有以下查询:
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)
我收到以下错误:
`Unknown connections.username in ON clause`
我在第一次加入时定义了一些条件,并希望得到与这些条件不匹配的其余条件。这就是我使用这部分的原因answers.id AND answers2.id
。获取与第一个左连接中的条件不匹配的 ID。
谢谢