Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Duplicate
-
5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
Description
I create and populate a table:
DROP TABLE t1; |
CREATE TABLE t1 (a INT); |
INSERT INTO t1 VALUES (10); |
INSERT INTO t1 VALUES (20); |
INSERT INTO t1 VALUES (30); |
Now I run this SQL Standard compliant query:
((SELECT a FROM t1) UNION (SELECT a FROM t1)); |
it returns a syntax error:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (SELECT a FROM t1))' at line 1
|
PostgreSQL and Oracle work fine on the same query.
This Standard-compliant query also returns a syntax_error:
(SELECT * FROM t1 UNION SELECT * FROM t1); |
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT * FROM t1)' at line 1
|
PostgreSQL and Oracle work fine on this query.
This query returns a syntax error:
((SELECT a FROM t1) LIMIT 1); |
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'LIMIT 1)' at line 1
|
It should return a result. It works fine in PostreSQL. Also, it is a direct equivalent query to this Standard-compliant version:
((SELECT a FROM t1) FETCH FIRST 1 ROWS ONLY); |
Another example:
SELECT * FROM (SELECT 1 UNION (SELECT 2 UNION SELECT 3)) t1; |
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION SELECT 3) t1' at line 1
|
The same query works in PostgreSQL.
A similar query works in Oracle (with FROM DUAL added, and with no derived table alias)
SELECT * FROM (SELECT 1 FROM DUAL UNION (SELECT 2 FROM DUAL UNION SELECT 3 FROM DUAL)) |
Attachments
Issue Links
- duplicates
-
MDEV-11953 support of brackets (parentheses) in UNION/EXCEPT/INTERSECT operations
- Closed
- relates to
-
MDEV-6341 INSERT ... SELECT UNION with parenthesis
- Closed
-
MDEV-8909 union parser cleanup
- Closed
-
MDEV-10029 UNION + OUTFILE is confusing
- Open