编辑 - 解决方案:
SELECT a.content as title, c.content as title_text, b.content as content FROM content_big AS b LEFT JOIN content_small AS a on a.id = 7 LEFT JOIN content_small AS c on c.id = 8 WHERE b.id = 1
我正在尝试做这样的选择:
可以使用1选择来获取这些数据吗?
我正在尝试此查询的一些变体:
SELECT content_small.content as title, content_small.content as title, content_big.content as content
FROM content_big LEFT JOIN
content_small
on content_small.id = 7 LEFT JOIN
content_small
on content_small.id = 8
WHERE content_small.content = 1
但是我收到了这个错误
不唯一的表/别名:'content_small'
答案 0 :(得分:0)
在联接上对表进行别名,如下所示:
SELECT cs1.content as title, cs1.content as title, content_big.content as content
FROM content_big LEFT JOIN
content_small cs1
on content_small.id = 7 LEFT JOIN
content_small cs2
on content_small.id = 8
WHERE cs2.content = 1
然后你就不会有命名冲突。