Gossamer Forum
Home : Products : DBMan : Customization :

Closest match search ?

Quote Reply
Closest match search ?
Can you please help me to do a closest macth search - ex. the user enter a zip code, and the script returns the the record containing the zip code with the closest match ?

Kenneth
Quote Reply
Re: Closest match search ? In reply to
I'd be interested in this also. Have you had any success with it Kenneth?

------------------
thanks,
Chris
Quote Reply
Re: Closest match search ? In reply to
You'd have to figure out the code for yourself, but the only way I can think of would be to do a search for all records and sort by the zip code field. Then go through each record to see how far removed the zip code in the record is from the target, stopping when you got to one that was larger than the target by a greater number than the last one that was smaller than the target.

(What did she say?! Smile )

If your target was 98031, and your list included 98025, 98029, 98030, 98032, 98035, you could stop testing after 98032. Of course, you would have two zip codes that were equally distant from the target.

You could probably speed it up a little by doing a search for the first three numbers of the zip code, if you have a large enough database that you could be pretty sure you'd be able to match the first three characters of any zip code that could be entered.


------------------
JPD
Quote Reply
Re: Closest match search ? In reply to
Hi,

You'd probably want something custom for this. Also, I didn't think zip codes were ordered geographically (i.e. there's no guarantee that 12345 is closer geographically to 34567 then to 78901). Or are you just trying to find the closest number regardless of geographic location?

Cheers,

Alex