Code Snippets
MySQL Snippets
The joins and the gotchas, copy-pasteable - the queries that are easy to get subtly wrong and the reasons they go wrong.
Everything in MySQL Snippets

09/27/2026
MySQL: get the latest row per group with ROW_NUMBER()
Get the latest row per group in MySQL 8+ with ROW_NUMBER(). Why MAX() subqueries and self-joins return duplicates on ties, and the tie-breaker to add.

12/21/2014
MySQL: exclude a whole group when any row matches
Querying databases get a little tricky when you have a stack of records associated with another table, perhaps a master table of accounts, and you’re trying to filter out values that would exclude the results from…