I have a function (SQL Server) I use to return values - see below
CREATE FUNCTION [dbo].[GetRelatedRecords] (@id bigint)
declare @results varchar(250)
SELECT @results = 'Related Record: ' + R.recordid
FROM RECORDS R
left join LINKS L
ON R.id = L.LinkID
WHERE L.id = @id
Assuming the value or R.Recordid = 'XYZ' then this will return 'Related Record: XYZ' which is great, but there are sometimes more than one match for L.id = @id and I'd like them all (rather than the last one which is what is currently returned.
So if the results were XYZ and ABC I need to return ''Related Records: XYZ|Related Records: ABC'