Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

list records with no lookup JOIN

Status
Not open for further replies.

thompom

Technical User
Dec 4, 2006
395
GB
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

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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top