
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 0.61 KB | hits: 20 | expires: Never
MySQL COALESCE alternative for selecting both result sets for an insert, not either / or?
INSERT INTO notification
(text, type, target_id, sender_id, recipient_id, data, timestamp, is_unread)
SELECT DISTINCT '$text', 'comment', '$id', '$senderId',
COALESCE(comment.author_id, stream.author_id),
'$dataArray','$timestamp', '1'
FROM stream
LEFT JOIN comment ON comment.target_id = stream.id
WHERE (comment.target_id = '$id' OR stream.id = '$id')
AND comment.author_id != '$senderId'"
AND stream.author_id != '$senderId'
select concat('a','b','c');
select concat_ws(',','a','b','c');