Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between " = null" and " IS NULL"?

Tags:

database

mysql

What is the difference between "=null" and "IS NULL"? How are they used differently?

like image 923
user329820 Avatar asked May 01 '10 05:05

user329820


People also ask

What is the difference between null and is null?

Null has a default value 0. it can be used as bool,integer, pointer. But C# null is used when we are not pointing to some object.

Why use IS null instead of null?

The concept is that NULL is not an equitable value. It denotes the absence of a value. Therefore, a variable or a column can only be checked if it IS NULL , but not if it IS EQUAL TO NULL .

Is null and null same in SQL?

null is well-defined value which may represent an unknown value, but it may also represent the absence of a value. It should be up to the developer to decide what null represents, but null itself is absolutely a value and null is null = null.

IS null or == null SQL?

In SQL null is not equal ( = ) to anything—not even to another null . According to the three-valued logic of SQL, the result of null = null is not true but unknown. SQL has the is [not] null predicate to test if a particular value is null .


1 Answers

In a WHERE clause, column=null will never be true, it is not valid to use null this way, you need to say column IS NULL or column IS NOT NULL. This speaks to the special nature of NULL, it is not a value to check for equality of, it is an unknown value, so you need to use the IS or IS NOT syntax.

You may assign something the NULL value using the = equal. For example: UPDATE TableX SET Column=NULL...

links:
Wikipedia NUll (SQL)
w3schools SQL NULL Values
SQL Tutorial, see IS NULL Operator section

like image 79
anonymous user Avatar answered Oct 05 '22 20:10

anonymous user