OsakaWebbie
Programmer
I'm moving a custom DB application from a hoster running MySQL 3.23 to a new hoster running MySQL 5.0. I am fully expecting syntax that needs fixing, but the first error I ran into I don't understand. Here is the SQL:
I get: "SQL Error 1054: Unknown column 'person.HouseholdID' in 'on clause'".
My person table does have a HouseholdID column, as it always did. The only difference between this and similar, working queries is the inclusion of the percat table and a WHERE statement to functionally "join" it to the person table, and the WHERE statement for the column CategoryID (in table percat - I'm asking for a list of people in a given category; percat makes a many-many relationship to a category table). The reason I did the query as multiple tables and a WHERE rather than an INNER JOIN has to do with the flow of the complex code that builds the SQL statement (possible criteria vary dramatically based on user input), but I suppose I could find another way to build the statement that makes the person-percat relationship an INNER JOIN. But this worked in 3.23 - can someone tell me why it doesn't in 5.0?
Code:
SELECT person.PersonID, FullName, Furigana, Email, CellPhone, Phone, TempAddress, postalcode.*, Address, person.Photo FROM person, percat
LEFT JOIN household ON person.HouseholdID=household.HouseholdID
LEFT JOIN postalcode ON household.PostalCode=postalcode.PostalCode
WHERE person.PersonID=percat.PersonID AND CategoryID = 56
ORDER BY Furigana
My person table does have a HouseholdID column, as it always did. The only difference between this and similar, working queries is the inclusion of the percat table and a WHERE statement to functionally "join" it to the person table, and the WHERE statement for the column CategoryID (in table percat - I'm asking for a list of people in a given category; percat makes a many-many relationship to a category table). The reason I did the query as multiple tables and a WHERE rather than an INNER JOIN has to do with the flow of the complex code that builds the SQL statement (possible criteria vary dramatically based on user input), but I suppose I could find another way to build the statement that makes the person-percat relationship an INNER JOIN. But this worked in 3.23 - can someone tell me why it doesn't in 5.0?