Today, there is a SQL that requires two fields that cannot be empty, and of course cannot be null or an empty string.
And then you start writing
1 Span style= "COLOR: #0000ff" >where 2 ( 3 order_amount != null 4 and order_ Amount != " 5 and received_amount != null 6 and Received_amount != " 7 )
Query results, not one!
Online Search only found:
Possible values for logical expressions in SQL include True, false, and unknown, which are called three-valued logic.
In other languages, there are only two types of logical expressions, either True or false. In SQL, there is a third logical expression, unknown, which is unique in SQL. From the literal meaning we can solve the meaning of the deserve value is: What do not know, is nothing. In general, when we compare any value (including null itself) to NULL, we will return unknown. In query expressions, such as where and have, unknown is considered false. So we figured out why the select * from table where field =null couldn't find the correct result.
But not all unknown will be treated as false, and in a check constraint, unknown is treated as true. This is why we can also insert a null value into the field if we set the value of a field to be greater than or equal to 0, because the logical result of null>=0 in the check constraint is unknown treated as true.
So, to determine the null value, use is not
1 WHERE2 (3Order_amount is not NULL 4 andOrder_amount!= "' 5 andReceived_amount is not NULL 6 andReceived_amount!= "'7)
SQL unexpectedly has such a rule, the gap between different languages is too big, each language has its own personalized things. Why programmers are difficult to do, because each language is different, and to do a project is often used in several languages, but also the development of language. I hope to have a language in the future for all scenarios: database, background, front end ...
SQL condition!=null data not found