FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
SQLiteSubqueries & ranked selection

Include every row tied for the highest score

SQLite: Compare with MAX rather than limiting to an arbitrary number of rows.

SQLite✓ Tested
SQLiteSubqueries & ranked selection

Include missing values in a not-equal filter

SQLite: Ordinary inequality does not include NULL; explicitly include it when that is the intended rule.

SQLite✓ Tested
SQLiteRelationships & missing data

Include zero counts for missing relationships

SQLite: Count the non-null child key after a left join so a missing relationship produces zero.

SQLite✓ Tested
SQLiteBulk changes & set operations

Increment a stored value in the database

SQLite: An in-database arithmetic update avoids a separate application read-modify-write step.

SQLite✓ Tested
SQLiteBulk changes & set operations

Insert only keys absent from a destination

SQLite: NOT EXISTS supports a set-based missing-row insert in a single-writer example.

SQLite✓ Tested
SQLiteRelationships & missing data

Join a parent to pre-aggregated totals

SQLite: Aggregate the child rows first to produce at most one joined row per parent.

SQLite✓ Tested
SQLiteGetting Started

Join related rows from two tables

SQLite: Match a category key to its display label with an explicit join condition.

SQLite✓ Tested
SQLiteRelationships & missing data

Join through a lookup table

SQLite: Use explicit aliases and join keys when enriching records through two relationships.

SQLite✓ Tested
SQLiteQueries & text

Join values with a delimiter

Concatenate rows in a specified order.

group_concat✓ Tested
SQLiteConstraints & defaults

Keep children while clearing a deleted relationship

SQLite: ON DELETE SET NULL requires a nullable foreign-key column.

SQLite✓ Tested
SQLiteRelationships & missing data

Keep parent rows while filtering joined children

SQLite: Put a child filter in ON when unmatched parents must remain in the result.

SQLite✓ Tested
SQLiteGetting Started

Keep rows matching a condition

SQLite: Use WHERE to select rows with a particular category.

SQLite✓ Tested