Hi,
I have two tables - 'action' and lookup table 'actiontype' - the sql below lists all values of actionttype table and shows actionid if there is a matching record in action table.
However a user can create a custom actionttype which is stored in the field 'action.typeid' - my problem is the records with custom 'typeid' are not displayed
is there a way to display records with 'action.typeid' even if there is no lookup record in 'actiontype' ?
plz note: 'action.typeid' is varchar
I have two tables - 'action' and lookup table 'actiontype' - the sql below lists all values of actionttype table and shows actionid if there is a matching record in action table.
However a user can create a custom actionttype which is stored in the field 'action.typeid' - my problem is the records with custom 'typeid' are not displayed
is there a way to display records with 'action.typeid' even if there is no lookup record in 'actiontype' ?
plz note: 'action.typeid' is varchar
Code:
SELECT TA.actionid, IF(ISNULL(TA.typeid),actiontype.action,TA.typeid) AS typeid
FROM actiontype
LEFT JOIN (SELECT action.actionid, action.typeid FROM action WHERE (action.eventid='5') ) AS TA ON TA.typeid = actiontype.action