Overview
TheIS DISTINCT FROM operator compares two values, considering them distinct even when both are NULL. It returns TRUE if the two values are different and FALSE if they are the same, including the case where both values are NULL.
Syntax
The syntax for the operator is as follows:value1is the first value for comparison.value2is the second value for comparison.
Examples
Case #1: Basic Usage
Consider the following example where we compare two values: Example 1Case #2: Comparing NULL Values
In this example, we’ll compareNULL values using the IS DISTINCT FROM operator:
Example 1
Case #3: Tracking Inventory Variations
Suppose we have a table namedinventory_changes that tracks changes in the quantities of products in a warehouse. The table has the following structure:
IS DISTINCT FROM operator can be used.