sql != query does not contain null data

In the recent work, the result set with the field value of "**" was to be excluded. When the reverse query was performed later, it was found that the number of records in the two query results was inconsistent with the total number of results without != as a condition. Finally, after analyzing the data, it was found that the use of != excluded Some values ​​in the field are also excluded when the value is NULL

If there are multiple fields, it is recommended to use not equal to sql

For example, the user table user has name, age, address fields to query to exclude address='Beijing'

select name, age, adress from user where (address != '北京' or adress is null) and (age >35 or age<25);

Please share if you understand the principle.

java learning exchange 513650703

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326308758&siteId=291194637