Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using two BETWEEN statments 1

Status
Not open for further replies.

3dColor

Programmer
Jan 10, 2006
240
US
I can use one BETWEEN statement in my query below just fine, but when i add the second one it doesn't return both ranges:

Code:
SELECT	csName, csId, stateFk, coords
FROM 	Cs
WHERE	stateFk = 1
	AND csId BETWEEN 53 AND 999
	AND csId BETWEEN 1001 AND 1006
 
Presumably you mean:
[tt]
AND
(
csId BETWEEN 53 AND 999
OR csId BETWEEN 1001 AND 1006
)
[/tt]
csID can't be within the first range and within the second range at the same time! If it's in either range it will satisfy the condition.
 
Oh yea, i wasn't think of it that way.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top