fastread homefastrread library fastread menu

SQL : IS NULL Condition

Tutorial by:Admin      Date: 2016-04-14 22:57:42

❰ Previous Next ❱

This SQL tutorial explains how to use the SQL IS NULL condition with syntax and examples.

Description

The SQL IS NULL condition is used to test for a NULL value in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax

The syntax for the SQL IS NULL condition is:

expression IS NULL

Parameters or Arguments

expression

The expression to test for a NULL value.

Note

  • If expression is a NULL value, the condition evaluates to TRUE.
  • If expression is not a NULL value, the condition evaluates to FALSE.

Example - With SELECT Statement

Let's look at an example of how to use IS NULL in a SELECT statement:

SELECT *

FROM suppliers

WHERE supplier_name IS NULL;

This SQL IS NULL example will return all records from the suppliers table where the supplier_name contains a NULL value.

Example - With INSERT Statement

Next, let's look at an example of how to use SQL IS NULL in an INSERT statement:

INSERT INTO suppliers

(supplier_id, supplier_name)

SELECT account_no, name

FROM customers

WHERE city IS NULL;

This SQL IS NULL example will insert records into the suppliers table where the city contains a NULL value.

Example - With UPDATE Statement

Next, let's look at an example of how to use SQL IS NULL in an UPDATE statement:

UPDATE suppliers

SET supplier_name = 'Apple'

WHERE supplier_name IS NULL;

This SQL IS NULL example will update records in the suppliers table where the supplier_name contains a NULL value.

Example - With DELETE Statement

Next, let's look at an example of how to use SQL IS NULL in a DELETE statement:

DELETE FROM suppliers

WHERE supplier_name IS NULL;

This SQL IS NULL example will delete all records from the suppliers table where the supplier_name contains a NULL value.

 

❰ Previous Next ❱