in reply to Algorythym for searching closest neighbor

Well, if you're using a DB (hopefully SQL, at least for this code) you could use a LIKE statement in there.

SELECT zdb.zip FROM zipdb zdb WHERE zdb.zip LIKE '%@query%'
I belive this may help. The %'s round the @query say match this in the beginning, middle, or end. I could be wrong, so look it up. (sybase is what I use)
Just my .02

_14k4 - webmaster@poorheart.com (www.poorheart.com)

Replies are listed 'Best First'.
Re: Re: Algorythm for searching closest neighbor
by physi (Friar) on Apr 03, 2001 at 17:17 UTC
    Well your select will find any number which contains your @query. So you will find
    @query=54321 654321 or 543210 but you will not find 54320 for example
    but when it's only numerical zip maybe the following will work:
    select min(abs(zip-@query)) from zipcodetable
    ----------------------------------- --the good, the bad and the physi-- -----------------------------------