Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Not a Bug
-
10.2
-
None
Description
I don't know if it is supposed to work; if it is not, please feel free to close as not a bug.
DROP TABLE IF EXISTS t1, t2; |
|
CREATE TABLE t1 (a INT); |
CREATE TABLE t2 (b INT); |
|
# This query works of course |
SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2 WHERE b = a ); |
|
# But this does not |
SELECT * FROM t1 WHERE EXISTS ( WITH cte AS ( SELECT * FROM t2 WHERE b = a ) SELECT * FROM cte ); |
MariaDB [test]> SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2 WHERE b = a ); |
Empty set (0.01 sec) |
|
MariaDB [test]> SELECT * FROM t1 WHERE EXISTS ( WITH cte AS ( SELECT * FROM t2 WHERE b = a ) SELECT * FROM cte ); |
ERROR 1054 (42S22): Unknown column 'a' in 'where clause' |
The example is oversimplified and probably does not make much sense, it's just meant to demonstrate the problem, but I guess there might more realistic cases affected by it.