samedi 23 juillet 2016

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

Aucun commentaire:

Enregistrer un commentaire