What is the difference between "=null" and "IS NULL"? How are they used differently?
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.
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 .
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.
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 .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With