我的命令有效,当我尝试再次插入它时,我不断收到此错误:每个派生表必须具有自己的别名。
这是我的命令:
SELECT s1.*
FROM subpages AS s1
INNER JOIN (
SELECT s2.*
FROM subsubpages AS s2
) ON s1.subpage_id = s2.subpage_id
WHERE s1.page_id = 18;
两个表的别名不同。为什么我仍然收到此错误?
答案 0 :(得分:2)
您需要子查询的别名:
SELECT s1.*
FROM subpages s1 INNER JOIN
(SELECT s2.*
FROM subsubpages s2
) s2
-------^ this one here
ON s1.subpage_id = s2.subpage_id
WHERE s1.page_id = 18;
注意:您的子查询完全没有必要。我建议您将其删除。
答案 1 :(得分:1)
您可以在下面尝试-需要为您的子查询添加别名
SELECT s1.* FROM subpages AS s1
INNER JOIN
(SELECT s2.* FROM subsubpages )AS s2
ON s1.subpage_id = s2.subpage_id WHERE s1.page_id = 18;
在我看来,您甚至不需要任何派生表-只需在下面遵循即可-
SELECT s1.* FROM subpages AS s1 join subsubpages s2
ON s1.subpage_id = s2.subpage_id WHERE s1.page_id = 18