MySQL Forums
Forum List  »  Other Migration

Re: MySQL 4 to MySQL 5 - SQL syntax question.
Posted by: Scott Gurley
Date: April 22, 2008 07:38AM

One thing I keep running into upgrading from MySQL4 to MySQL5 is a difference in LEFT JOIN... for example

SELECT users.name, department.name as department, countries.name as country FROM users, departments LEFT JOIN countries on users.country = countries.uid

[I'm faking this as I type - ignore any typos)

The above WILL work in MySQL4 but not in MySQL5! I'm not sure why it is different but to get it working in MySQL5 the above query needs to be:

SELECT users.name, department.name as department, countries.name as country FROM (users, departments) LEFT JOIN countries on users.country = countries.uid

I simply added parenthesis around the table names. All fixed.

Options: ReplyQuote


Subject
Views
Written By
Posted
11305
September 08, 2006 07:46AM
Re: MySQL 4 to MySQL 5 - SQL syntax question.
5337
April 22, 2008 07:38AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.