DarkMantis
DarkMantis

Reputation: 1516

Difference between = and IS mysql

So I am on a site at the moment where it has an interactive MySQL Shell prompt.

I was looking up a question that a friend asked which is "why does the query fail when I use the keyword IS but it works when I use the = symbol?"

So I tested it out and sure enough it does fail.

SELECT name, continent, population FROM world WHERE continent IS 'Asia' failed but SELECT name, continent, population FROM world WHERE continent = 'Asia' works fine.

I have tried googling for an answer but no avail.

Any help would be great!

Upvotes: 6

Views: 1384

Answers (1)

Sam
Sam

Reputation: 2761

IS tests against a boolean(True/False/NULL neither) where as = tests equivalency

IS can only be used against variables that return true, false or NULL .

Upvotes: 11

Related Questions