MySQL Forums
Forum List  »  Newbie

Re: Display CONCAT() from second table if not NULL
Posted by: Christopher Esbrandt
Date: October 22, 2014 12:07PM

I have a solution. The LEFT JOIN was on the right track, but I needed a LEFT OUTER JOIN with a CASE statement.

SELECT p.name, CASE WHEN u.id IS NOT NULL THEN CONCAT(u.lastName, ', ', u.firstName) ELSE null END AS user, p.dueDate
FROM projects p
LEFT OUTER JOIN users u
ON p.uid = u.id
ORDER BY p.id DESC;

Thank you for the help. ^^

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.