【发布时间】:2021-05-17 13:59:16
【问题描述】:
所以我有三个表:tabe_1, table_2, table_3,我将使用字段A 来映射前两个表,因为它包含在table_1 和table_2 中,然后加入@987654325 @ 带有字段B 和C,然后在其上添加一些过滤器(例如:where 语句),查询是:
SELECT *
FROM
(select *
from table_1 t1
join table_2 t2
on t1.A = t2.A
join table_3 t3
on t1.B = t3.B
and t1.C = t3.C) AS output_table
WHERE output_table.xx = xxx
这给了我错误:Error Code: 1060. Duplicate column name 'A'
但是如果我只查询子查询:
select *
from table_1 t1
join table_2 t2
on t1.A = t2.A
join table_3 t3
on t1.B = t3.B
and t1.C = t3.C
这将返回 output_table,有人可以看看嵌套查询发生了什么吗?谢谢。
【问题讨论】:
-
你在子查询中使用
select *。列出子查询中的列。 -
是的,请看上面的查询:
FROM (select * from.......) AS output_table -
列出子查询中的列而不是使用
select *。我认为我之前的评论很混乱。
标签: mysql sql mysql-workbench