In SQL SERVER I need to output row data from a table while joining with another table and column data in second table should be comma separated for each first table row by a single query. If there is no matching rows in second table, It should Display NULL. Following are the tables.
Table 1 Table 2
ID Name Tlb1_ID CITY
1 A 1 ZZ
2 B 1 XX
3 C 2 GG
4 D 2 HH
5 E 3 JJ
I want the output is as follows Result
ID Name CITY
1 A ZZ,XX
2 B GG,HH
3 C JJ
4 D NULL
5 E NULL