I need some alternative of implode for mysql queries.After research found concat functions.
Question is, can I concat by whitespace like that CONCAT_WS(' ',sender.fname, sender.mname, sender.lname) AS sender_name ? is there any chance that it will give error if one of values is null?
Here is my query.
SELECT message.id, message.from_id, message.to_id, message.subject,
message.date, message.deleted, message.read,
CONCAT_WS(' ',sender.fname, sender.mname, sender.lname) AS sender_name,
CONCAT_WS(' ',recipient.fname, recipient.mname, recipient.lname) AS recipient_name,
FROM msghistory AS message
LEFT JOIN users AS sender ON sender.id=message.from_id,
LEFT JOIN users AS recipient ON recipient.id=message.to_id
GROUP BY message.id DESC
One more question, in this query CONCAT_WS(' ',recipient.fname, recipient.mname, recipient.lname) AS recipient_name might not be found (if there is no matched row in users table). Will this give any error?