Note: All underscore + italic statements are optional statements
SQL statement:
Select… From… Where 列名 is not null…
Note that "=null" is not allowed
Summary of null value handling in current DBMS:
- A null value does not satisfy any lookup criteria except is not null
- If null participates in an arithmetic operation, the value of the arithmetic expression is null
- If null participates in the comparison operation, the result can be regarded as 0 (can be regarded as unknown in SQL-92)
- If null participates in the aggregation operation, other aggregation functions except count(*) ignore null
Example ①: Find the names of students whose age value is empty
Select Sname From Student Where Sage is null;
Example ②: the following table:
Select AVG(Score) From SC → the result is (92+55)/2 = 73.5
Select COUNT(*) From SC → result is 3