2

I have one table booking that have value like belw

id           email 
1           a@a.com
2           a@a.com 
3           b@b.com
4           c@c.com
5.          c@c.com       

I want output like this

email       id
a@a.com     1,2
b@b.com     3
c@c.com     4,5

can you suggest how i can do this.

Cœur
  • 37,241
  • 25
  • 195
  • 267
nitin jain
  • 298
  • 6
  • 19

1 Answers1

4

In MysQL, use GROUP_CONCAT function

SELECT email, GROUP_CONCAT(id) id
FROM tableName
GROUP BY email
John Woo
  • 258,903
  • 69
  • 498
  • 492