Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the column name return from join is ambiguous #2

Open
jjtjiang opened this issue Feb 26, 2021 · 0 comments
Open

the column name return from join is ambiguous #2

jjtjiang opened this issue Feb 26, 2021 · 0 comments

Comments

@jjtjiang
Copy link

jjtjiang commented Feb 26, 2021

`the column name return from join is ambiguous ,sometimes it return the table.column_name and sometimes it return the column_name rather than table.column_name;

CREATE TABLE test.a
(
id Int8,
name String
)
ENGINE = Memory

insert into a values (1,'name') ;

SELECT *
FROM
(
SELECT *
FROM a
) AS a1
INNER JOIN
(
SELECT *
FROM a
) AS a2 ON a1.id = a2.id
┌─id─┬─name─┬─a2.id─┬─a2.name─┐
│ 1 │ name │ 1 │ name │
└────┴──────┴───────┴─────────┘

this case return column_name;

SELECT *
FROM
(
SELECT *
FROM a
) AS a1
INNER JOIN
(
SELECT *
FROM a
) AS a2 ON a1.id = a2.id
INNER JOIN
(
SELECT *
FROM a
) AS a3 ON a2.id = a3.id

┌─a1.id─┬─a1.name─┬─a2.id─┬─a2.name─┬─a3.id─┬─a3.name─┐
│ 1 │ name │ 1 │ name │ 1 │ name │
└───────┴─────────┴───────┴─────────┴───────┴─────────┘

this case return table.column_name;`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant