Web Hosting Talk







View Full Version : RAnge Query


Qumber
07-21-2003, 07:15 AM
I created a table called ShipZip that includes One Column named ShipZIPCode this Has One reocrd of ZIP Range Like 760 - 780 . From the ShipZip table, I want to return this Record When I have 770 as searching criteria . For example, 770 falls in ranges: (760 - 780), How can I return that data?

luki
07-22-2003, 12:15 AM
Create a table with two columns zip_min and zip_max, plus others if you need them. The you can run a query:

SELECT * FROM ShipZIP WHERE $zip>=zip_min AND $zip<=zip_max

($zip is the ZIP code you want to look up).

So if $zip is 770 and you have a table with a row like this:
zip_min, zip_max
760, 780

the above query will work fine.