Plain-English SQL query builder

Fill in the sentence and the query writes itself, for MySQL, PostgreSQL or DuckDB. Nothing you type leaves your browser.

Try:

in in infromin, showing , newest by , ties broken by whose has no match in .from to , including days with none

for each ,

sorted by

and show at most rows.

What can it write?

Start the sentence withYou get
Show the rowsThe matching rows, with the columns you list, sorted and limited.
Count the rows, Add up, Average, Find the smallest or largest, Count the different valuesOne total, or one per group when you fill in "for each".
Keep the newest row for eachOne row per ID: the newest by date, with an optional tie-breaker. Conditions apply to that newest row, so "status is blocked" means blocked now.
Find rows inRows with no match in another table, such as customers with no orders.
Count rows per day ofEvery date in the range, with 0 on days that had nothing.

Why is "is not" written that way?

In SQL, status <> 'done' quietly skips rows where status is empty, because a comparison with an empty value is neither true nor false. Most people asking for "status is not done" want those rows too, so the builder adds OR status IS NULL. Delete that part if you want empty rows left out.

Why does the query differ between databases?

Most of it doesn't. The differences are where the databases genuinely disagree: MySQL quotes names with backticks and has no generate_series, so the daily count builds its dates with a recursive query instead, and MySQL's LIKE already ignores case where PostgreSQL and DuckDB need ILIKE. Values are always written in quotes, which all three accept for number and date columns too.

For the reasoning behind the trickier patterns, see keep the latest status row per task, find projects with no tasks and fill missing days with zero.

How was this builder checked?

The site's tests build every kind of query this page writes, run each one on sample tables in DuckDB 1.5.6, MySQL 8.4 and PostgreSQL 17, and check the rows that come back, including empty values, quotes inside values, and days with nothing on them. That happens on every rebuild. Your own tables can still surprise it, for example a date stored as text, so run the query on a copy or add a row limit first.

Esc