Mysql Left Join Null Result?

Use: SELECT a. *, COALESCE(u. Username, 'User Not Found') AS `user` FROM ARTICLES a LEFT JOIN USERS you ON u.Id = a.

User_id ORDER BY articles. Timestamp Documentation: COALESCE The reason to choose COALESCE over IF or IFNULL is that COALESCE is ANSI standard, while the other methods are not reliably implemented over other databases. I would use CASE before I'd look at IF because again - CASE is ANSI standard, making it easier to port the query to other databases.

Thanks so much :) – Ozzy May 24 '10 at 0:19 gota wait 8 minutes to accept... :P – Ozzy May 24 '10 at 0:20.

You can use the IFNULL function: SELECT articles. *, IFNULL(users. Username, 'User Not Found') AS `user` FROM `articles` LEFT JOIN `users` ON articles.

User_id = users. Id ORDER BY articles.timestamp.

You can use IF() where in Oracle you would have used decode. So SELECT articles. *, IF(users.

Username=NULL,'No user found',users. Username )AS `user` FROM `articles` LEFT JOIN `users` ON articles. User_id = users.Id ORDER BY articles.

Timestamp Should work. Note: I don't have mysql handy, so did not test the query. But should work with minor modifications if it fails.

Do not downvote ;).

SELECT articles. *, IFNULL(users. Username,'User Not Found') AS `user` FROM `articles` LEFT JOIN `users` ON articles.

User_id = users. Id ORDER BY articles.timestamp.

– OMG Ponies May 24 '10 at 0:25 Not recommended. :) – Christian Jonassen May 24 '10 at 0:34.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions