NYCPHP Meetup

NYPHP.org

[nycphp-talk] zipcode lookup

Aaron Deutsch aaron at aarond.com
Tue Dec 4 12:59:21 EST 2007


sent on behalf of a co-worker....


I am building a zip code area UI.

For instance, a resource is assigned a range of zip codes that they can
recruit prospective clients from.

The table fields are: RESOURCE_CODE | ZIPCODE

Each available zip code is listed with the relative resource code.

My problem is the query.  On the UI end I don't want to list all 1000 zips
for a resource, I'd like to show ranges where possible (e.g. 07748;
07750-07790) in a delimited format. I can then do the inserts without any
issues.

Is there a way in Oracle to recognize row values that have an increment of
one from the previous row in order to split them into a range? Therefore, if
I wanted the zips from code M99 it would return any single zips and ranges
(07750-07790) as opposed to listing them individually.

Requested Row Output Example:

Row1: 07748

Row2: 07750-07790

And so on..


I can do this with PHP, but I figure if Oracle can do it the application
would be a lot faster.

I believe another way to do this would be to change the chapter table to
have low and high values, but I'd still have the problem of initially
populating the new table with the ranges.

Also, I'm sure there are other ways do this. If I'm off track please guide
me.


Thanks for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20071204/7e6d0d13/attachment.html>


More information about the talk mailing list