Matches null vs.

I have a rough understanding of why = nullSQL is nulldoesn't match, from issues like this .

But then why

update table 
set column = null

valid SQL statement (at least in Oracle)?

From this answer, I know that it nullcan be considered somewhat “UNKNOWN”, and therefore sql-statement with where column = null“should” return all rows, because the value is columnno longer an unknown value. I set it to nullexplicitly;)

Where am I mistaken / don't understand?

So, if my question is perhaps unclear: Why is it = nullpermissible in a statement set, but not in a wherestatement, of an SQL statement?

+4
source share
3 answers

SQL does not have different graphic characters for assignment and equality operators, such as c or is. In such languages =, the assignment operator , and ==the equality operator. In SQL, it is =used for both cases and is interpreted contextually.

The sentence where =acts as an equality operator (similarly ==in C). Ie, it checks if both operands are equal, and returns trueif they are. As you already mentioned, nullit is not meaning - it is the lack of meaning. Therefore, it cannot be equal to any other value.

set = ( = C). I.e., ( ) . - , .

+6

, .

  • where

- allosw "" " ".

+6

set , NULL. where . , , .

+2

Source: https://habr.com/ru/post/1584189/


All Articles