Skip to content
100% local

SQL WHERE clause builder

Turn a list of values into a SQL WHERE condition with IN lists, ranges and LIKE patterns.

Output

SQL WHERE clause builder

Paste a list of values and this tool assembles a ready-to-use SQL WHERE condition around them — an IN list, a BETWEEN range, a LIKE pattern, or a simple comparison — without you having to hand-type quotes, commas and parentheses. It is built for the everyday case of turning a spreadsheet column or a query result into the next query's filter.

Choose the column name, the operator, and how multiple conditions combine (AND or OR). IN and NOT IN collapse every value into one list, automatically split into smaller batches once the list passes the size you set, so long lists stay within a database's parameter limits — batches for IN are joined with OR, and batches for NOT IN with AND, since that is what keeps the logic equivalent to a single unsplit list. BETWEEN reads each entry as a low:high pair. The value type (string, number or date) controls whether values are wrapped in quotes, and every apostrophe inside a string is escaped automatically so a name like O'Brien can't break the query. Pick a SQL dialect to get the right identifier quoting for a column name that needs it — backticks for MySQL, square brackets for SQL Server, double quotes elsewhere.

Alongside the literal clause, the tool always produces a parameterized version with the placeholder style you choose — plain question marks, numbered $1/$2 placeholders, or named placeholders derived from the column — plus the list of values in the order they need to be bound. Blank lines in the value list are skipped by default, or turned into an extra "OR column IS NULL" clause when you want NULL rows included in the result.

Everything runs locally in your browser; the values you paste are never uploaded anywhere. Copy the result, download it as a .txt file, or send the output back into the input to keep refining it.

FAQ

How do I write a range for BETWEEN?
Each line is a low:high pair, for example 10:20. Lines that aren't a valid pair are skipped and counted separately.
What happens to a long list with the IN operator?
Once the list is longer than the batch size you set, it is split into several IN (...) groups joined with OR, which keeps every database happy about how many parameters one query can bind.
Does it escape apostrophes for me?
Yes. Every single quote inside a string or date value is doubled, so a value like O'Brien becomes 'O''Brien' and can't break the generated SQL.
What is the parameterized output for?
It's the version you'd actually bind in code — with ?, $1/$2, or named placeholders instead of literal values — shown together with the values in the order they need to be passed.
Is my data uploaded anywhere?
No. The clause is built entirely in your browser; the values you enter never leave your device.