Bug #3524 | the of inner join performed on a result of out join it is a cross product | ||
---|---|---|---|
Submitted: | 21 Apr 2004 7:55 | Modified: | 27 Apr 2004 16:35 |
Reporter: | Philip | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S2 (Serious) |
Version: | 4.0.16-max-debug/ 4.0.18-log | OS: | i686 GNU/Linux/Windows |
Assigned to: | Dean Ellis | CPU Architecture: | Any |
[21 Apr 2004 7:55]
Philip
[27 Apr 2004 16:35]
Dean Ellis
The real issue is that you are attempting to use nested joins, which MySQL does not currently support. The unpredictable results are due to MySQL silently ignoring the parentheses which produce your nesting. Support for nested joins is scheduled for a future release, however.
[4 May 2004 16:35]
Philip
I still believe it is a bug because if it just ignores the parenthesis we have two consecative ON | USING clauses which shoul,d be a syntax error. And indeed it is if using only 2 tables. ## gives syntax error SELECT f.fid, s.sid FROM first AS f LEFT JOIN second AS s USING(fid) ON f.fid = s.fid; ## gives syntax error SELECT f.fid, s.sid FROM first AS f LEFT JOIN second AS s ON f.fid = s.fid ON f.fid = s.fid; ## oops no syntax error SELECT f.fid, s.sid, t.sid FROM first AS f INNER JOIN second AS s LEFT JOIN third AS t ON s.sid=t.sid ON s.sid=t.sid; Maybe the bug is not with the joins and nested joins. And speaking about the statement: logically the ‘ON f.fid=s.fid’ must be assigned to the tables it belongs to. i.e. SELECT f.fid, s.sid, t.sid FROM first AS f INNER JOIN second AS s ON f.fid=s.fid LEFT JOIN third AS t ON s.sid=t.sid; Which is the best solution but if not the parser must throw a syntax error.
[4 May 2004 16:38]
Philip
Sorry, in my previous message after the text: “ And speaking about the statement:” I forgot to put the statement: SELECT f.fid, s.sid, t.sid FROM first AS f INNER JOIN (second AS s LEFT JOIN third AS t ON s.sid=t.sid) ON f.fid=s.fid;