Page 1 of 1

How to NOT select years from XX to XX ??

Posted: Fri May 16, 2008 2:06 am
by camarosource
Which is the proper syntax to indicate I want to SELECT ALL from user_submissions where the field CAMARO_YEAR is NOT BETWEEN 1967 and 2002?

For example let's say someone put "67" or "88" or "198" or something.. It should SELECT those because it's not between "1967 - 2002"


I tried :

$sql_cal09 = "SELECT * FROM user_submissions WHERE CAMARO_YEAR NOT IN BETWEEN '1967' AND '2002' ORDER BY SUBMISSION_ID";

and

$sql_cal09 = "SELECT * FROM user_submissions WHERE CAMARO_YEAR NOT BETWEEN ('1967', '2002') ORDER BY SUBMISSION_ID";

but it's selecting ALL.. even tho the "CAMARO_YEAR" is between 1967 and 2002.. The "NOT" is not being read properly.

Thanks

Re: How to NOT select years from XX to XX ??

Posted: Fri May 16, 2008 2:59 pm
by kendall
well i think it would have worked

mysql documentations has
expr NOT BETWEEN min AND max

This is the same as NOT (expr BETWEEN min AND max).