In a MSSQL table ("username"), I have the two following records:
name ¦ nickname
John Johny
Marc Marco
I'd like to do a query that would return "Johny, Marco" when I as k for the nicknames of John and Marc.
I've tried the following:
declare @consolidatedNicknames varchar(2000)
set @consolidatedNicknames = ''
select @consolidatedNicknames = @consolidatedNicknames + nickname + ';'
From username WHERE name IN ('John','Marc')
but it only returns me the nickname of 'John'.
How could it concat the nickname of 'John' AND 'Marc' ?
Many thanks.