How to order WHERE / NOT / BETWEEN

Hello there,

I'm very new to SQL and have a question that might sound basic, but I really don't understand...

Objective: To query data of customers whose customer IDs are not between 10 and 35 from customers table

SELECT * from customers
WHERE customerID NOT BETWEEN 10 AND 35

SELECT * from customers
WHERE NOT customerID BETWEEN 10 AND 35

Both 1) and 2) run successfully in the program. So can "NOT" be placed either next to WHERE or after customerID? If yes then which option is more typical to write? (option 1 looks better in my opinion)

Thank you very much in advance.

image

Yes, and, you are correct, #1 is the normal way to code that.

1 Like

Thank you!