Page 1 of 1

Smaller than but larger than

Posted: Thu Aug 27, 2009 1:16 pm
by JellyFish
Hello wonderful community! I haven't been on in awhile so I thought I'd might ask a quick SQL question.

Is there a way, in SQL, to accomplish a comparison that says x is larger y than but also smaller than z, like:

Code: Select all

 
... WHERE COLUMN < 11 AND COLUMN > 0; #column is x, 11 is y, and 0 is z.
 
Is there some operator that allows me to do this differently, or is the way I have just done it the best? I guess what I'm asking is, is there a better way to check to see if a value is within a specific range from y-z than what I've just wrote?

Thanks for reading.

Re: Smaller than but larger than

Posted: Thu Aug 27, 2009 1:24 pm
by jackpf
You can use BETWEEN...AND.

Re: Smaller than but larger than

Posted: Thu Aug 27, 2009 1:49 pm
by JellyFish
Oh thanks, just what I was looking for! You're awesome!

EDIT: Also, a note to readers: I would have to change my y and z variables to 10 and 1 respectively. This is because BETWEEN ... AND matches true when the expression is equal to either the min or max.