sqlcmd.net validated sql reference

#null

Commands grouped around the same concept, pattern, or recurring problem.

12 commands with this tag Browse related patterns quickly
beginner null-handling MySQL MariaDB SQL Server PostgreSQL SQLite

Check For NULL Values With IS NULL

Use `IS NULL` and `IS NOT NULL` to filter rows based on whether a column has a value.

intermediate null-handling MySQL MariaDB SQL Server PostgreSQL SQLite

Compare Values Including NULLs Safely

Match rows where two values are equal, treating two NULLs as equal instead of unknown.

intermediate sorting MySQL MariaDB SQL Server PostgreSQL SQLite

Control Where NULLs Appear in a Sort

Use `NULLS FIRST` or `NULLS LAST` to explicitly position NULL values at the top or bottom of a sorted result set.

intermediate updating MySQL MariaDB SQL Server PostgreSQL SQLite

Convert Blank Strings To NULL

Normalize empty or whitespace-only text values to `NULL` with `NULLIF(TRIM(...), '')`.

intermediate casting MySQL MariaDB SQL Server PostgreSQL

Convert Values Without Errors Using Safe Casting

Convert strings to numbers (or other types) while returning `NULL` for values that cannot be converted, instead of raising an error that aborts the query.

beginner data-quality MySQL MariaDB SQL Server PostgreSQL SQLite

Count Missing Values Per Column

Audit a table for `NULL` values by counting how many rows have no value in each column of interest.

intermediate joining MySQL MariaDB SQL Server PostgreSQL SQLite

Find Rows With No Match Using An Anti-Join

Return rows from one table that have no corresponding row in a second table using a LEFT JOIN with a NULL check.

intermediate joins MySQL MariaDB SQL Server PostgreSQL SQLite

Find Rows With No Matching Related Row

Use a `LEFT JOIN` and filter for `NULL` on the joined table to find missing relationships.

beginner conditional-logic MySQL MariaDB SQL Server PostgreSQL SQLite

Replace NULL Values With COALESCE

Return the first non-null value from a list of expressions.

intermediate null-handling MySQL MariaDB SQL Server PostgreSQL SQLite

Return NULL When Two Values Are Equal With NULLIF

Use `NULLIF` to convert a specific value to `NULL`, most commonly to prevent division-by-zero errors.

beginner aggregation MySQL MariaDB SQL Server PostgreSQL SQLite

Understand COUNT(column) Versus COUNT(*)

`COUNT(column)` skips `NULL` values, while `COUNT(*)` counts every row that made it into the result set.

intermediate null-handling MySQL MariaDB SQL Server PostgreSQL SQLite

Use NOT IN Safely When NULLs Are Possible

Filter `NULL` values out of the right side before using `NOT IN`, or the predicate can exclude everything.