This query runs fine on MySQL 4.1.22.
SELECT pc.id AS pendingChangeID, pc.pending_change_type as changeType, pc.foreign_key as changedItemID, pc.submitted_on as submittedOn, pc.submitted_by as accountID, a.username as username, IFNULL(c.name, CONCAT(p.first_name, ' ', p.last_name)) as changedItemName
FROM pending_changes pc, account a
LEFT JOIN company c
ON (pc.pending_change_type='COMPANY') AND (c.id=pc.foreign_key)
LEFT JOIN person p
ON (pc.pending_change_type='PERSON') AND (p.id=pc.foreign_key)
WHERE a.id=pc.submitted_by
However, on MySQL 5.0.22 it reports this error:
Error Code : 1054
Unknown column 'pc.pending_change_type' in 'on clause'
The field does in fact exist. What's the problem here?