Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
5.5, 10.0, 10.1, 10.2
-
None
-
10.2.14
Description
This query:
SELECT * FROM |
t1 NATURAL JOIN t2 |
LEFT JOIN |
t3 NATURAL JOIN t4 |
USING (a);
|
produces an 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 'USING (a)' at line 4
|
This is a wrong behavior. It's a valid query according to the standard.
Oracle and PostgreSQL support this.
The problem here is that the USING clause is related to the LEFT JOIN operation, while MariaDB tries to apply it to the second NATURAL JOIN.
According to the Standard, NATURAL and CROSS joins have higher precedence over OUTER and INNER joins.
So the above query should mean exactly the same with:
SELECT * FROM |
(t1 NATURAL JOIN t2) |
LEFT JOIN |
(t3 NATURAL JOIN t4) |
USING (a);
|
which works fine and does not produce syntax errors.