SELECT *
FROM (SELECT 1 AS A, 2 AS B) A
JOIN (SELECT 1 AS C, 4 AS D) B ON A.A = B.C
输出: -
A B C D
1 2 1 4
答案 0 :(得分:1)
这是因为你选择了“*”。 这意味着你想拥有A和B的所有东西。
如果您只想选择“OR”B中的列,则查询应如下所示:
SELECT A.*
FROM (SELECT 1 AS A, 2 AS B) A JOIN
(SELECT 1 AS C, 4 AS D) B
ON A.A = B.C
OR
SELECT B.*
FROM (SELECT 1 AS A, 2 AS B) A JOIN
(SELECT 1 AS C, 4 AS D) B
ON A.A = B.C