Related knowledge points about SQL NULL values

Source: Internet
Author: User
A NULL value is an unknown data that is missing. By default, the columns of the table can hold NULL values. This chapter explains the is null and is not NULL operators.

SQL NULL Value

If a column in the table is optional, we can insert a new record or update an existing record 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 non-applicable values.

Note: Cannot compare NULL and 0; they are not equivalent.

NULL Value handling for SQL

Take a look at the following table:

If the "Address" column in the "Persons" table is optional. This means that if you insert a record with no value in the Address column, the address column is saved with a NULL value.

So how do we test for NULL values?

You cannot use a comparison operator to test for NULL values, such as =, <, or <>.

We must use the is null and is not NULL operator.

SQL is NULL

How do we just pick a record with a NULL value in the "Address" column?

We must use the IS NULL operator:

SELECT lastname,firstname,address from Persons
WHERE Address is NULL

:

This article is related to SQL NULL to explain, more learning materials clear focus on the PHP Chinese network can be viewed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.