Possible Duplicate:
Concatenate row values T-SQL
I have a table like this:
ref_num name type route
----------------------------------------
1 A W 401
2 B X 401
3 C E 401
3 C E 411
4 D Z 401
5 K W 701
5 K W 991
5 K W 556
5 K W 401
6 L X 401
7 D Y 401
7 D Y 411
7 D Y 680
8 E Z 401
And i want a RESULT like this:
ref_num name type routes
----------------------------------------
1 A W 401
2 B X 401
3 C E 401,411
4 D Z 401
5 K W 701,991,556,401
6 L X 401
7 D Y 401,411,680
8 E Z 401
If anybody can give me a query example to get the desired result it would be greatly appreciated
In MySQL you don’t have to
group byall values you are selecting. Other values will probably selected by random. But if the other values are the same in one group then you don’t have to worry. That is the case in the OP’s question.