SQL – NULL Values

Table Of Contents:

  1. What Are NULL Values?
  2. Syntax Of NULL Values.
  3. Examples Of Null Values.

(1) What Are NULL Values ?

  • Sometimes users don’t enter every asked value in the input form.
  • If a column doesn’t have any value in it there will be NULL inside it.
  • Database replaces the empty values with ‘NULL’.
  • A field with a NULL value is one that has been left blank during record creation!

(2) Syntax Of NULL Values ?

Syntax:

NULL
SELECT column_names
FROM table_name
WHERE column_name IS NULL;
SELECT column_names
FROM table_name
WHERE column_name IS NOT NULL;

Note:

  • NULL values are identified with the “NULL” keyword.

(3) Examples Of NULL Values ?

Demo Data:

Example-1:

SELECT CustomerName, ContactName, Address
FROM Customers
WHERE Address IS NULL;

Example-2:

SELECT CustomerName, ContactName, Address
FROM Customers
WHERE Address IS NOT NULL;

Leave a Reply

Your email address will not be published. Required fields are marked *