SELECT [B]music_albums.*[/B],users.username,inventory.stock,inventory.upc_code, DATE_FORMAT(release_date,'%M %d, %Y') AS rel FROM music_albums,users LEFT JOIN inventory ON ([B]inventory.album_id=music_albums.id[/B]) WHERE users.uid=music_albums.artist_id AND music_albums.id='8'
This has worked perfectly on mysql 4. Now, with mysql 5+, it gives this error:
#1054 - Unknown column ‘music_albums.id’ in ‘on clause’
How does it not recognize the column music_albums.id ? What do I have to do differently, from now on, for mysql 5? I am testing our site on php 5/mysql 5 to make sure our site won’t break before we update our servers.
Thanks.
PS. Edit: I see it was a feature change and am reading the mysql docs but I think I need coffee to understand it…but for those going through the same thing, look at this page:
SELECT music_albums.*,users.username,inventory.stock,inventory.upc_code, DATE_FORMAT(release_date,‘%M %d, %Y’) AS rel FROM music_albums,users,inventory WHERE users.uid=music_albums.artist_id AND music_albums.id=‘8’ limit 1
get out of the habit of using comma join syntax. stick specifically with INNER and OUTER joins. The problem you encounter is mysql 5 being more conforming with sql standards.
the comma takes precedence over the LEFT (OUTER) join and thus it can’t find the column inventory.album_id because it is only looking at music_albums and users and trying to perform that join first.
SELECT
music_albums.*,
users.username,
inventory.stock,
inventory.upc_code,
DATE_FORMAT(release_date,'%M %d, %Y') AS rel
FROM
music_albums
INNER JOIN
users
ON
users.uid=music_albums.artist_id
LEFT JOIN inventory
ON
inventory.album_id=music_albums.id
WHERE
music_albums.id=8