F-M-A F-M-A - 5 months ago 13
MySQL Question

Mysql get values from all rows but in one record by comma separated

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

Answer

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.

Comments