Reuben Gomes Reuben Gomes -5 years ago 138
MySQL Question

SQL Group by name

I have a table

a | bc
a | dc
a | ef
a | gh
a | ij

I want to create a group by so that it shows

a |bc

I'm currently using

select(*) from 'tablename' group by city;

Answer Source

Not pretty sure if this is what you want, but if you want to get all rows from locality for a in one new cell, you can use this.

SELECT *, GROUP_CONCAT(locality) as localities FROM table GROUP BY city

This will output:

city    localities 
a       bc, dc, ef, gh, ij
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download