SELECT * FROM usm_groups
LEFT JOIN (
	SELECT rog_group_id,
	GROUP_CONCAT(rog_role_id ORDER BY rog_role_id) AS role_ids_concat,
	GROUP_CONCAT(role_name ORDER BY rog_role_id) AS role_names_concat,
	GROUP_CONCAT(IF(rog_read,1,0) ORDER BY rog_role_id) AS role_reads_concat,
	GROUP_CONCAT(IF(rog_write,1,0) ORDER BY rog_role_id) AS role_writes_concat,
	GROUP_CONCAT(role_color ORDER BY rog_role_id) AS role_colors_concat
	FROM usm_roles_on_groups
	JOIN usm_roles ON rog_role_id = role_id
	GROUP BY rog_group_id
) roles ON rog_group_id = group_id
WHERE 
	(ISNULL(:ids) AND group_id != 1) OR
	group_id IN (:ids)
