JOIN syntax changes in MySQL 5

Migrate applications to MySQL 5 could need some rewrite. Here is one example :

mysql5> SELECT * FROM table0, table1 JOIN table2 on table0.colA = table2.colB;
ERROR 1054 (42S22): Unknown column 'table0.colA' in 'on clause'

That’s because JOIN operator has now higher priority. Previously, this request was interpreted like ((table 0, table1) JOIN table2) and now it is (table 0, (table1 JOIN table2)). A fast fix is adding parenthesis:

mysql5> SELECT * FROM (table0, table1) JOIN table2 on table0.colA = table2.colB;

You can find more information in MYSQL bug #13832 and in MySQL manual (See Join Processing Changes in MySQL 5.0.12 section).

Comments are closed.