我有两张桌子......
夹具
和团队
现在我想展示两队(lteam和vteam)的名字 彼此在一张桌子里。我曾尝试 LEFT JOIN 这些表,但这不起作用。猜猜你知道为什么吗?
SELECT * FROM fixtures
LEFT JOIN teams as a ON fixtures.lteam = teams.id
LEFT JOIN teams as b ON fixtures.vteam = teams.id
WHERE date_ko = '2017-05-19'
感谢您的帮助!
答案 0 :(得分:2)
联接不正确。改变这个:
LEFT JOIN teams as a ON fixtures.lteam = teams.id
LEFT JOIN teams as b ON fixtures.vteam = teams.id
|
对此:
LEFT JOIN teams as a ON fixtures.lteam = a.id
LEFT JOIN teams as b ON fixtures.vteam = b.id
|
您还需要在连接中使用别名