开发者

Parsing location string - MySQL query

开发者 https://www.devze.com 2023-01-28 23:37 出处:网络
I\'m working a a location search box and I was wondering if you guys could give me some help. I\'ve looked through so开发者_如何学JAVAme resources and managed to get working city search with spelling

I'm working a a location search box and I was wondering if you guys could give me some help.

I've looked through so开发者_如何学JAVAme resources and managed to get working city search with spelling correction. It basically searches for exact matches, if none are found, it searches for double metaphone matches and limits them by the (levenshtein/length)<0.5 .

I'd like to implement a way to parse states (and if possible neighborhoods).

My question is:

Is there a way for MySQL to search for the city (and state)? What I mean is, is there a way for me to split the string and pass the parts to MySQL without knowing what each part is? (what part is city and which is state)

I'm thinking about this because I'd like to have spelling correction/guessing instead of just looking through the string with an array of correctly spelled states - similar to the way I have it with the cities.

There is probably an easy way to do this, I'm just mentally fatigued from getting the current city search working. I'd appreciate any help on this. Thanks.

Edit:

The tables,their fields and one sample row:

Cities:

Parsing location string - MySQL query

States

Parsing location string - MySQL query


you can concatenate the city and state columns in the DB and query on the combination like:

where concat(city, state) = city_state
0

精彩评论

暂无评论...
验证码 换一张
取 消