Upgrading to MySQL 5 from MySQL 4

The largest upgrade issue we experienced in upgrading from MySQL 4 to MySQL 5 was in the select statement from multiple tables.

To help you on your way (if you have not-well formatted queries) we provide this example:

MySQL 4 query: SELECT * FROM X, Y, Z WHERE A and B and C

MySQL 5 query: SELECT * FROM (X, Y, Z) WHERE A and B and C

The reason: Apparently, in MySQL 5, there is some confusion as to where the fields come from, even if they are uniquely named and labeled with the table name preceding the field name. Without the parens to collect the tables from which the data is selected, it is the default action of MySQL 5’s interpreter to consider only either the first or last table in the list of tables. This means that the query executed without parens will leave some of the fields in the where conditions without proper assignment/definition, and the query will fail.

Share/Save/Bookmark

Leave a Reply