SQL WHERE clause builder
Turn a list of values into a SQL WHERE condition with IN lists, ranges and LIKE patterns.
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.