Mysql Left Join Null Result

Posted by Ozzy on Stack Overflow See other posts from Stack Overflow or by Ozzy
Published on 2010-05-24T00:12:54Z Indexed on 2010/05/24 0:20 UTC
Read the original article Hit count: 351

Filed under:
|
|
|

I have this query

SELECT articles.*, 
       users.username AS `user` 
 FROM `articles` 
LEFT JOIN `users` ON articles.user_id = users.id 
 ORDER BY articles.timestamp 

Basically it returns the list of articles and the username that the article is associated to. Now if there is no entry in the users table for a particular user id, the users var is NULL. Is there anyway to make it that if its null it returns something like "User Not Found"? or would i have to do this using php?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql