Bug #15227 unknown column in LEFT JOIN
Submitted: 24 Nov 2005 14:42 Modified: 24 Nov 2005 14:48
Reporter: Tomasz Budzynski Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.16-standard OS:Linux (Linux Debian)
Assigned to: Assigned Account CPU Architecture:Any

[24 Nov 2005 14:42] Tomasz Budzynski
Description:
i've got this query:
SELECT p.*, d.kod as dzial, d.nazwa AS dzial_nazwa, k.opis AS kategoria, k.kod AS kod_kategorii, k.id_wp AS id_wp, k.id_onet AS id_onet, n.nazwa AS nadkategoria, n.id AS id_nk 
FROM produkty AS p, dzialy AS d 
LEFT JOIN nadkategorie AS n ON  n.id = p.id_nk 
LEFT JOIN kategorie AS k ON  k.id = p.id_kat 
WHERE p.id = 1 AND d.id = p.id_dzial 
GROUP BY p.id

it was fine working on my last version of mysql (5.0.11-beta), today i was upgrading my system, and i've decided to upgrade mysql, and i've got this bug.
i've checked all the tables and all columns are there.
this is the error msg:
#1054 - Unknown column 'p.id_nk' in 'on clause' 

if i change left joins with places
like that
LEFT JOIN kategorie AS k ON  k.id = p.id_kat 
LEFT JOIN nadkategorie AS n ON  n.id = p.id_nk 
i've got this error msg:
#1054 - Unknown column 'p.id_kat' in 'on clause' 

on versions 5.0.11-beta, 4.1.11, 4.1.15 all works fine.

How to repeat:
...

Suggested fix:
i have no idea
[24 Nov 2005 14:48] MySQL Verification Team
Thank you for the bug report. Duplicate of bug:

http://bugs.mysql.com/bug.php?id=13551

Please read:

http://dev.mysql.com/doc/refman/5.0/en/news-5-0-12.html

#

Incompatible change: Beginning with MySQL 5.0.12, natural joins and joins with
USING,
including outer join variants, are processed according to the SQL:2003
standard.
The changes include elimination of redundant output columns for NATURAL joins
and joins
specified with a USING clause and proper ordering of output columns. (Bug #6136,
Bug #6276,
Bug #6489, Bug #6495, Bug #6558, Bug #9067, Bug #9978, Bug #10428, Bug #10646,
Bug #10972.)
The precedence of the comma operator also now is lower compared to JOIN. (Bug
#4789,
Bug #12065, Bug #13551.)

These changes make MySQL more compliant with standard SQL. However, they can
result in
different output columns for some joins. Also, some queries that appeared to
work correctly
prior to 5.0.12 must be rewritten to comply with the standard. For details about
the scope
of the changes and examples that show what query rewrites are necessary, 
see Section 13.2.7.1, “JOIN Syntax”.

http://dev.mysql.com/doc/refman/5.0/en/join.html