My SQL - GROUP_CONCAT() for Concatenate Many Rows Into a Single Text String

Concatenate Many Rows Into a Single Text String with GROUP_CONCAT() in My SQL









SELECT p.`id`,p.`permission_name`,GROUP_CONCAT(g.`group_name` ORDER BY g.`group_name` ASC SEPARATOR ', ') AS 'group_name',p.`date_created`,p.`date_modified`,p.`status`
FROM `permission` p JOIN `permission_detail` pd ON p.`id`=pd.`permission_id`
      JOIN `groups` g ON pd.`group_id`= g.`id`
WHERE p.`status` IS NULL
GROUP BY p.`id` 
ORDER BY p.`date_modified` DESC














Post a Comment

0 Comments