SELECT 
obj_main.isys_obj__id AS '__id__', 
 (CONCAT(obj_main.isys_obj__title, ' {', obj_main.isys_obj__id, '}')   ) 'isys_cmdb_dao_category_g_global__title' , 
 (SELECT isys_catg_global_category__title
                                FROM isys_catg_global_list
                                JOIN isys_catg_global_category
                                  ON isys_catg_global_list__isys_catg_global_category__id = isys_catg_global_category__id  WHERE isys_catg_global_list__isys_obj__id = obj_main.isys_obj__id  AND isys_catg_global_list__status = 2   ) 'isys_cmdb_dao_category_g_global__category' , 
j5.isys_catg_address_list__city 'isys_cmdb_dao_category_g_address__city', 
 (SELECT REPLACE(CONCAT('<ul><li>', GROUP_CONCAT((CASE
                              WHEN isys_catg_contact_list__primary_contact > 0 THEN CONCAT(isys_obj__title, ' {', isys_obj__id, '}', ' (LC__CATG__CONTACT_PRIMARY)')
                              ELSE CONCAT(isys_obj__title, ' {', isys_obj__id, '}') END) SEPARATOR '</li><li>'), '</li></ul>'), '<ul><li></li></ul>', '')
                            FROM isys_catg_contact_list
                            INNER JOIN isys_connection ON isys_connection__id = isys_catg_contact_list__isys_connection__id
                            INNER JOIN isys_obj ON isys_obj__id = isys_connection__isys_obj__id AND isys_obj__status = 2  WHERE isys_catg_contact_list__isys_obj__id = obj_main.isys_obj__id  AND isys_catg_contact_list__status = 2   GROUP BY isys_catg_contact_list__isys_obj__id  ) 'isys_cmdb_dao_category_g_contact__contact_list' , 
 (SELECT REPLACE(CONCAT('<ul><li>', GROUP_CONCAT(CONCAT(isys_obj__title, ' {', isys_obj__id, '}', ' (', isys_contact_tag__title, ')') SEPARATOR '</li><li>'), '</li></ul>'), '<ul><li></li></ul>', '')
                            FROM isys_catg_contact_list
                            INNER JOIN isys_connection ON isys_connection__id = isys_catg_contact_list__isys_connection__id
                            INNER JOIN isys_obj ON isys_obj__id = isys_connection__isys_obj__id AND isys_obj__status = 2
                            LEFT JOIN isys_contact_tag ON isys_contact_tag.isys_contact_tag__id = isys_catg_contact_list.isys_catg_contact_list__isys_contact_tag__id  WHERE isys_catg_contact_list__isys_obj__id = obj_main.isys_obj__id  AND isys_catg_contact_list__status = 2   GROUP BY isys_catg_contact_list__isys_obj__id  ) 'isys_cmdb_dao_category_g_contact__contact_list_with_roles'  

FROM isys_obj AS obj_main 
LEFT JOIN isys_catg_address_list AS j5 ON j5.isys_catg_address_list__isys_obj__id = obj_main.isys_obj__id AND j5.isys_catg_address_list__status = 2 

WHERE TRUE 
AND obj_main.isys_obj__isys_obj_type__id = 52 
