Tuesday, 15 July 2014

MySQL select to find similar lat/lng with matching name column -



MySQL select to find similar lat/lng with matching name column -

i trying find rows in single table of locations have same latitude/longitude when rounded 2 decimal places same name. here table (for example):

+---------------------------------------+ | id | lat | lng | name | +---------------------------------------+ | 11 | -11.119 | 13.891 | smith's place | | 81 | -11.121 | 13.893 | smith's place | +---------------------------------------+

what select statement find instances (like 1 above) lat/lng match when rounded 2 decimal places...and names same?

i looking similar query doesn't work (but asking after):

select * pb_locations grouping round(lat,2),round(lng,2) name = name having count(id) > 1

where name = name true, since it's comparing within same row, not across different rows.

you need set 3 columns in group by clause.

select * pb_locations grouping round(lat, 2), round(lng, 2), name having count(*) > 1

mysql

No comments:

Post a Comment