SQL IS NOT NULL Keyword

The IS NOT NULL operator in SQL is used to filter rows in a table, selecting only those rows where a particular column has a value (it's not NULL).



IS NOT NULL: Definition and Usage

In SQL, NULL represents the absence of a value. The IS NOT NULL operator is essential for excluding rows with missing or undefined data in a specific column. You can't use standard comparison operators (like !=) to test for NULL; you must use IS NULL or IS NOT NULL.

Syntax

Syntax

SELECT column1, column2, ...
FROM table_name
WHERE column_name IS NOT NULL;
      

Example

Selecting Customers with Addresses

This query retrieves the 'CustomerName', 'ContactName', and 'Address' for all customers who have an address listed (i.e., where the 'Address' column is not NULL). (This assumes a 'Customers' table with these columns.)

Syntax

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

CustomerName                      | ContactName      | Address
--------------------------------------------------------------------
(Customer names with addresses) | (Contact names)  | (Addresses)
      

**Note:** The example output shows a general structure. The specific customer data displayed depends entirely on the contents of your `Customers` table. If any customers have a `NULL` value in the `Address` column, those rows would *not* be included in this output.