SQL query guide and searchable reference
117 searchable queries, patterns and gotchas — with runnable examples.
117 entries · arrow keys to move, Enter to open
Pick an entry
Or search above — the list covers syntax, recipes and the traps.
Every example on this page runs against the same small schema, so they read as one database rather than a pile of unrelated snippets:
users(id, email, name, country, status, created_at)orders(id, user_id, total, status, placed_at)order_items(id, order_id, product_id, qty, unit_price)products(id, name, category, price, active)About the SQL query guide
How it works in 4 steps · 4 common use cases · 4 questions answered
About the SQL query guide
How it works in 4 steps · 4 common use cases · 4 questions answered
How it works
- 1.Type what you are trying to do — duplicate, latest per user, upsert, pagination — or browse a category.
- 2.Search covers titles, summaries, tags, examples and notes, so a keyword from the query text finds the entry too.
- 3.Open an entry for its syntax, a runnable example, what it does, the traps, and the dialect differences.
- 4.Copy the example with one click, or copy the link — every entry is its own URL you can paste into a review.
Common use cases
- •Remembering the exact syntax for an upsert or a window frame mid-task
- •Finding the standard query for duplicates, top N per group or a running total
- •Checking why a LEFT JOIN quietly dropped rows, or why NOT IN returned nothing
- •Looking up how a query differs between PostgreSQL, MySQL, SQL Server and Oracle
FAQ
Which SQL dialect do the examples use?
They are written in standard SQL, leaning on PostgreSQL syntax where the standard is ambiguous. Entries whose syntax genuinely differs carry dialect notes for PostgreSQL, MySQL, SQL Server, Oracle and SQLite.
Can I link to a single entry?
Yes. Selecting an entry puts its id in the URL, so the link you paste into a pull request or a chat opens on the same entry, with the same search and category filter.
Do the examples run as written?
They target one small sample schema — users, orders, order_items and products, shown on the page — so they read as one coherent database. Swap in your own table and column names.
How is this different from the SQL Formatter?
The formatter pretty-prints a query you already have. This page is the reference for writing one. They sit next to each other in the menu.