You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem is fixed if the columns are given aliases as follows:
SELECT *
FROM (
SELECT a1.x AS x1, a1.y AS y1, a2.x AS x2, a2.y AS y2
FROM (
SELECT *
FROM test
) AS a1 JOIN (
SELECT *
FROM test
) AS a2 ON a1.x = a2.x
) AS t;
Indeed we do not handle the first query correctly as it has ambiguous names.
Comment 19054
Date: 2013-08-23 10:04:56 +0200
From: Robin Cijvat <>
Ok, but the syntax of the outer query suggests that everything gets selected that is selected in the inner query, despite the naming of the columns. In the case it is left this way, won't it be a good idea to at least let this sort of construct trigger an error? Otherwise it might lead to confusion or even the usage of wrong query results if someone (like myself) assumes wrong things about these sort of queries.
Date: 2013-08-22 11:34:40 +0200
From: Robin Cijvat <>
To: SQL devs <>
Version: 11.15.11 (Feb2013-SP3)
CC: @njnes
Last updated: 2013-09-27 13:47:13 +0200
Comment 19051
Date: 2013-08-22 11:34:40 +0200
From: Robin Cijvat <>
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.89 Safari/537.36
Build Identifier:
Instead of showing the left and right result next to each other, the right result is displayed twice next to each other.
Reproducible: Always
Steps to Reproduce:
Execute the following SQL:
CREATE TABLE test (x int, y int);
insert into test (x, y) VALUES (1, 1);
insert into test (x, y) VALUES (1, 2);
SELECT *
FROM (
SELECT a1.x, a1.y, a2.x, a2.y
FROM (
SELECT *
FROM test
) AS a1 JOIN (
SELECT *
FROM test
) AS a2 ON a1.x = a2.x
) AS t;
Actual Results:
+------+------+------+------+
| x | y | x | y |
+======+======+======+======+
| 1 | 1 | 1 | 1 |
| 1 | 2 | 1 | 2 |
| 1 | 1 | 1 | 1 |
| 1 | 2 | 1 | 2 |
+------+------+------+------+
Expected Results:
+------+------+------+------+
| x | y | x | y |
+======+======+======+======+
| 1 | 1 | 1 | 1 |
| 1 | 1 | 1 | 2 |
| 1 | 2 | 1 | 1 |
| 1 | 2 | 1 | 2 |
+------+------+------+------+
Problem is fixed if the columns are given aliases as follows:
SELECT *
FROM (
SELECT a1.x AS x1, a1.y AS y1, a2.x AS x2, a2.y AS y2
FROM (
SELECT *
FROM test
) AS a1 JOIN (
SELECT *
FROM test
) AS a2 ON a1.x = a2.x
) AS t;
Comment 19053
Date: 2013-08-23 09:44:22 +0200
From: @njnes
Indeed we do not handle the first query correctly as it has ambiguous names.
Comment 19054
Date: 2013-08-23 10:04:56 +0200
From: Robin Cijvat <>
Ok, but the syntax of the outer query suggests that everything gets selected that is selected in the inner query, despite the naming of the columns. In the case it is left this way, won't it be a good idea to at least let this sort of construct trigger an error? Otherwise it might lead to confusion or even the usage of wrong query results if someone (like myself) assumes wrong things about these sort of queries.
Comment 19055
Date: 2013-08-23 10:55:59 +0200
From: @njnes
added an error for duplicate column names
Comment 19056
Date: 2013-08-23 11:42:02 +0200
From: MonetDB Mercurial Repository <>
Changeset 2810a6a4ef0e made by Niels Nes niels@cwi.nl in the MonetDB repo, refers to this bug.
For complete details, see http//devmonetdborg/hg/MonetDB?cmd=changeset;node=2810a6a4ef0e
Changeset description:
The text was updated successfully, but these errors were encountered: