2
Below is my table

-----------------------------------
|id|     |Zone|    |State         |
--------------------------
|1|     |Zone1|    | State1,State2|

|2|     |Zone2|    | State3,State4|

|3|     |Zone3|    | State5|

I try with group concatenate it shows 3 different records, I want in one record all concatenated by comma like

State1, State2, State3, State4, State5

I try with this query

select group_concat(state separator ',') as state from zone group by title
F-M-A
  • 43
  • 8

2 Answers2

4

Please tell me what is "title" field in your table. You can try select group_concat(state separator ',') as state from zone. Do not use group by title.

kaushik karan
  • 351
  • 2
  • 7
3

Group By title

SELECT group_concat(state) as State 
FROM zone GROUP BY title;

To get all data in comma separated data in single row

SELECT group_concat(state) as State 
FROM zone;

Refer : http://sqlfiddle.com/#!9/9d5aa/1

zakhefron
  • 1,403
  • 1
  • 9
  • 13