liveBook · Manning

Is not null operator

As explained in Learn SQL in a Month of Lunches

IS NOT NULL is an SQL predicate that tests whether an expression has a non-null value.

Use IS NOT NULL when a query should keep only rows where a column contains a value. For example, it can find authors who have a middle name. section 7.2.3

SELECT
    FirstName,
    MiddleName,
    LastName
FROM author
WHERE MiddleName IS NOT NULL;

This query returns each author's first, middle, and last name only when MiddleName is not NULL. section 7.2.3

Read IS NOT NULL as “is not missing.” The predicate can also produce the same result as MiddleName LIKE '%' in this text-column example: the percent wildcard matches stored string data, while NULL represents no data. section 7.2.3

Preventing an incomplete promotion

A stored procedure can test IF _PromotionCode IS NOT NULL THEN before inserting a promotion. A supplied code allows the insert; passing NULL skips it, so the call with promotion ID 15 produces no row. section 21.2.1

How Learn SQL in a Month of Lunches covers it

How deep it goes
Demonstrates predicate syntax in SELECT and IF statements, then verifies matching and skipped database changes.
Examples
Uses author middle names, a promotion-code validation procedure, and calls with both a real code and NULL.
What it assumes
Assumes familiarity with filtering rows and NULL values, while introducing the plain-language meaning of “is not.”
What you can do after
Apply it via SQL queries and stored-procedure conditions to select or insert records only when values exist.
How it connects
Connects NULL values with WHERE filtering, wildcard matching, IF conditions, stored procedures, and INSERT statements.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn SQL in a Month of Lunches. The section links point to the parts of the book it draws on.