Nehil Mistry
Nehil Mistry

Reputation: 1109

Filter same data in table Mysql

My table structure is something like this

╔════════╦══════════╦══════════╗
║     ID ║ OUTLET   ║ LAT      ║
╠════════╬══════════╬══════════╣
║      1 ║ OUTLET1  ║ 19.0000  ║
║      2 ║ OUTLET2  ║ 19.0000  ║
║      3 ║ OUTLET3  ║ 19.5236  ║
║      4 ║ OUTLET4  ║ 19.4756  ║   
╚════════╩══════════╩══════════╝

I am expecting output something like this

╔═════════════════╦══════════╗
║ OUTLET          ║ LAT      ║
╠═════════════════╬══════════╣
║ OUTLET1, OUTLET2║ 19.0000  ║
║ OUTLET3         ║ 19.5236  ║
║ OUTLET4         ║ 19.4756  ║   
╚═════════════════╩══════════╝

Is there any way I can get this output. I don't know how to filter out rows in same table. Help please.

Upvotes: 0

Views: 32

Answers (1)

Abhik Chakraborty
Abhik Chakraborty

Reputation: 44864

You can use group_concat and group by

select 
group_concat(OUTLET) as OUTLET,
`LAT`
from table_name
group by `LAT`

Upvotes: 2

Related Questions