LenaLD
LenaLD

Reputation: 95

How to use "IS" and "=" in MySQL in the right way

Trying to figure out when to use "is", "=" since it seems like these two don't work the same way in SQL.

I've tried to switch these two in different commands, and I thought I'd receive the same result, but seems like SQL would only recognize one of them with particular functions

WHERE event_date **=** '2013-12-22'

And I tried to use "IS" instead of "=" for the above command

WHERE event_date **IS** '2013-12-22'

Then I got an error code, also in another practice question. I wanted to use "IS" before "BETWEEN", that failed too. 

WHERE affected_customers BETWEEN 50000 AND 150000

I tried to put 

WHERE affected_customers IS BETWEEN 50000 AND 150000

Upvotes: 0

Views: 189

Answers (2)

kapitan
kapitan

Reputation: 2212

SQL operators don't necessarily need to be use like how you construct an English sentence.

IS operator is usually use with the NULL operator, hence IS NULL and IS NOT NULL - used to checked if a value is NULL.

affected_customers BETWEEN 50000 AND 150000 is enough and logical, you'll get use to it as you go along with your programming life.

Best of luck to your journey!

Upvotes: 1

fifonik
fifonik

Reputation: 1606

IS word cannot just be added before another operator.

IS operator is used for checking value against boolean

IS NULL and IS NOT NULL are used for checking values against NULLs.

Upvotes: 2

Related Questions