How to NOT select years from XX to XX ??

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
camarosource
Forum Commoner
Posts: 77
Joined: Sat Aug 03, 2002 10:43 pm

How to NOT select years from XX to XX ??

Post 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
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

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

Post 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).
Post Reply