SELECT bioRecordKey, taxonName,genus,family,'','',countryName,localityText,collection_code,institution_code,gatheringDate,bioRecordId,bioRecordResourceKey,geoLongitude,geoLatitude,taxonAuthor,recordBasis,collector,collectorNumber,fieldNumber,resourceName,cast(urls as text)
from  bioRecord
INNER join taxon ON taxon.taxonKey = bioRecordTaxonKey   
LEFT join isoCountry on isoCountryCode = bioRecordCountryCode 
LEFT join imageRecord on imagerecordbiorecordkey = bioRecordKey 
LEFT JOIN resource on resourceKey = bioRecordResourceKey 
CROSS APPLY
(
	select imagerecordurl + ' '
	from imageRecord
	where imageRecordBioRecordKey = bioRecord.bioRecordKey
	for XML path ('')
) pre_trimmed (urls)
WHERE bioRecordKey IN (5178, 5896, 7208)  
GROUP BY bioRecordKey, taxonName,genus,family,countryName,localityText,collection_code,institution_code,gatheringDate,bioRecordId,bioRecordResourceKey,geoLongitude,geoLatitude,taxonAuthor,recordBasis,collector,collectorNumber,fieldNumber,resourceName,urls
