I have first table t1
||ID||name||add||
|t1|a|kl|
second table t2
||id||t1ID||Photo
|1|t1|image url
|2|t1|image url
I want to get row from first table and then csv of photo from second table
I ran below query
select sp.*, STUFF(( SELECT ',' + photo
FROM t2
FOR
XML PATH('')
), 1, 1, '') as Photo from t2 sp
left join t2 ig on sp.idID = ig.t1id
where sp.id = 4
It returns correct value but two rows, since second column have two rows for first table t1 id.
how should I can only one row means for each row of first table it should return csv photo in last column
THanks