fuzzy DISTINCT Values

Posted by user982853 on Stack Overflow See other posts from Stack Overflow or by user982853
Published on 2012-08-28T18:36:42Z Indexed on 2012/08/29 3:38 UTC
Read the original article Hit count: 255

Filed under:
|
|
|
|

I have a database of real estate listings and need to return a list of neighborhoods. Right now I am using mysql DISTINCT which returns all of the distinct values. My probelm is that there is a lot of neighborhoods that have similar names: example:

Park View Sub 1
Park View
Park View Sub 2
Park View Sub 3
Great Lake Sub 1
Great Lake Sub 2
Great Lake 
Great Lake Sub 3

I am looking for an easy php or mysql solution that would recognize that "Park View" and "Great Lake" already exists and ONLY return "Park View" and "Great Lake".

My initial thought is to some how get the sort order by length so that the short values are at the top and then loop through using strstr. This sound like a large task I am wondering if there is a function either in mysql or php that would easily do this.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql