Bug #21276 | Subqueries are being interpreted incorrectly | ||
---|---|---|---|
Submitted: | 25 Jul 2006 14:54 | Modified: | 26 Aug 2006 8:56 |
Reporter: | Erica Moss | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Parser | Severity: | S2 (Serious) |
Version: | 5.0.25 -log | OS: | Linux (Fedora core 5) |
Assigned to: | Georgi Kodinov | CPU Architecture: | Any |
[25 Jul 2006 14:54]
Erica Moss
[25 Aug 2006 18:09]
Omer Barnir
Correcting the description since there is a typo in it: "...there is no column 'a' in table t2, therefore..." should have said: "...there is no column 'a' in table t1, therefore...
[26 Aug 2006 8:56]
Sergei Golubchik
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/. Where is a bug here ? According to the name resolution rules, a column reference is first looked up in a subquery, then in an outer query. Thus, as 'a' in the subquery is not found in a t1, it is looked up in t2. The query becomes SELECT t2.a FROM t2 WHERE t2.a IN (SELECT t2.a FROM t1); here WHERE condition is always true, and the query does simply SELECT a FROM t2; as expected