{sql:SELECT her_core.watprn as 'PRN', her_core.name as 'Name',her_core.summary as 'Summary',geo_locations.ngr as 'NGR',geo_locations.east as 'X',geo_locations.nrth as 'Y',geo_locations.unitary as 'Unitary Authority',geo_locations.community as 'Community',her_core.html_link as 'Link',
IFNULL(GROUP_CONCAT(DISTINCT her_core_site_type.period ORDER BY her_core_site_type.period DESC SEPARATOR ',' ),'-') as `Period`,
IFNULL(GROUP_CONCAT(DISTINCT her_core_site_type.type ORDER BY her_core_site_type.type DESC SEPARATOR ',' ),'-') as `Type`,
IFNULL(GROUP_CONCAT(DISTINCT her_core_site_type.broadclass ORDER BY her_core_site_type.broadclass DESC SEPARATOR ',' ),'-') as `Broadclass`,
IFNULL(GROUP_CONCAT(DISTINCT her_condition.condition ORDER BY her_condition.condition DESC SEPARATOR ',' ),'-') as `Condition`,
IFNULL(GROUP_CONCAT(DISTINCT her_status.status ORDER BY her_status.status DESC SEPARATOR ','),'-') as `Status`,
IFNULL(GROUP_CONCAT(DISTINCT her_status.reference ORDER BY her_status.reference DESC SEPARATOR ','),'-') as `Status Ref`
FROM her_core
LEFT JOIN geo_locations ON her_core.watprn = geo_locations.watprn
LEFT JOIN her_core_site_type ON her_core.watprn = her_core_site_type.watprn
LEFT JOIN her_status ON her_core.watprn = her_status.watprn
LEFT JOIN her_condition ON her_core.watprn = her_condition.watprn
where `her_core`.`watprn` IN(search_selection(`her_core`) and (her_core.restricted = '0' or her_core.restricted IS NULL))
GROUP BY her_core.watprn
}