Page 1 of 1

query help :(

Posted: Mon Oct 21, 2002 12:42 pm
by JPlush76
I'm having a brain fart and can't think of the best way to call this query.

basically what I have to do is take the first 3 numbers of a zip code and compare that with a range of numbers to give a zone

my zone table

їcode]
zone zip1 zip2
2 900 933
3 934 934
7 600 639
ї/code]
so basically if the zip is 922 then the zone = 2

I can get the first 3 numbers fine with substring but its the actual query call I'm having probs with. Maybe I even setup the table wrong.

anyone? thanks!

Posted: Mon Oct 21, 2002 12:51 pm
by twigletmac
http://www.mysql.com/doc/en/Comparison_Operators.html

Check out BETWEEN:

Code: Select all

SELECT zone FROM table WHERE code BETWEEN zip1 AND zip2
untested but it's probably something like that...

Mac

Posted: Mon Oct 21, 2002 12:53 pm
by JPlush76
twiglet I heart you.

it worked

I didn't think I could use fields in the between clause

I thought it was used .. WHERE age BETWEEN 20 AND 40

thanks again!