asfaran
asfaran

Reputation: 25

Return mutiple value for on column in sql select

For Example This is my table(copied).

id  customer        product 
1   Tizag           Pen 
4   Gerald Garner   19" LCD Screen  
5   Tizag           19" LCD Screen  
6   Gerald Garner   clock

I want to select the whole table. And the result has to be like this:

customer        product 
Tizag           Pen,19" LCD Screen
Gerald Garner   19" LCD Screen,clock

How can I do this?

Upvotes: 2

Views: 99

Answers (2)

Nishant
Nishant

Reputation: 3694

No need to use "," as seperator , it comes by default

 select customer, group_concat(product) as product
 from tableName
 group by customer

Upvotes: 1

Amit Singh
Amit Singh

Reputation: 8119

Select customer ,
Group_Concat(product SEPARATOR ',') as Product
from TableName group by customer    

SQL Fiddle Demo

Upvotes: 3

Related Questions