Related knowledge points about SQL NULL values

jacklove
Release: 2023-03-25 16:22:02
Original
1670 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!