Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between = and IS mysql

Tags:

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!

like image 300
DarkMantis Avatar asked Dec 04 '13 22:12

DarkMantis


1 Answers

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 .

like image 78
Sam Avatar answered Sep 27 '22 21:09

Sam