Home  >  Article  >  Backend Development  >  Related knowledge points about SQL NULL values

Related knowledge points about SQL NULL values

jacklove
jackloveOriginal
2018-05-08 11:31:481687browse

NULL values ​​are missing unknown data. By default, table columns can store NULL values. This chapter explains IS NULL and IS NOT NULL operators.

SQL NULL value

If a column in the table is optional, then we can insert new records or update existing records without adding a value to the column. This means that the field will be saved with a NULL value.

NULL values ​​are handled differently than other values.

NULL is used as a placeholder for unknown or inapplicable values.

Comments: NULL and 0 cannot be compared; they are not equivalent.

SQL NULL value processing

Please see the following table:

Related knowledge points about SQL NULL values

If the "Address" column in the "Persons" table is available Chosen. This means that if you insert a record without a value in the "Address" column, the "Address" column will be saved with a NULL value.

So how do we test for NULL values?

You cannot use comparison operators to test for NULL values, such as =, .

We must use the IS NULL and IS NOT NULL operators.

SQL IS NULL

How do we select only records with NULL values ​​in the "Address" column?

We must use the IS NULL operator:

SELECT LastName,FirstName,Address FROM Persons
WHERE Address IS NULL

:

Related knowledge points about SQL NULL values

This article explains SQL NULL. For more learning materials, please pay attention to the php Chinese website.

Related recommendations:

Explanation of knowledge related to SQL Date function

Explanation of knowledge related to SQL VIEW (view) Explanation

#Explanation about SQL AUTO INCREMENT field

The above is the detailed content of Related knowledge points about SQL NULL values. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn