How to use the SQL IN Clause Generator
- Paste your values — copy a column from Excel or Google Sheets, or paste a comma-separated list.
- Choose the output form, column name and table, and whether to use
NOT IN. - Quoting is automatic: numbers stay unquoted, text is wrapped in single quotes with apostrophes escaped.
- Copy the SQL into your query. Use groups of 1,000 for Oracle.
What is a SQL IN clause?
The IN operator tests whether a value matches any item in a list. It is shorthand for a chain of OR conditions and is the usual way to look up a batch of records you already have IDs for — for example a column of order numbers someone sent you in a spreadsheet:
SELECT *
FROM orders
WHERE id IN ('A-1001', 'A-1002', 'B-2040');
Typing the quotes and commas by hand for hundreds of values is tedious and easy to get wrong. This generator does it in one paste.
Quoting and escaping
| Input | Auto quoting |
|---|---|
1001, 1002 (all numbers) | (1001, 1002) |
A-1001, B-2040 | ('A-1001', 'B-2040') |
O'Neil | 'O''Neil' — the apostrophe is doubled |
| Unicode text in SQL Server | N'Zoë' with the N prefix option |
Use Always when a numeric-looking column is stored as text (for example ZIP codes or phone numbers), so the database does not have to convert types and can use its index.
Limits per database
- Oracle allows at most 1,000 expressions in one IN list (error ORA-01795). Set groups of 1,000 and the generator joins them with
OR. - SQL Server has no fixed limit, but statements with many thousands of values parse slowly; use a temporary table or table-valued parameter instead.
- MySQL is limited by
max_allowed_packet; PostgreSQL can also take an array:WHERE id = ANY('{1,2,3}').
Safety note
Pasting generated lists is fine for ad-hoc queries in a database client. In application code, never build SQL by concatenating user input — use parameterised queries. Format long queries with the SQL Formatter, and remove duplicate lines from other lists with Remove Duplicate Lines.
Tools that pair well with the SQL IN Clause Generator
- CREATE TABLE Generator — Design a table column by column — types, primary key, NOT NULL, UNIQUE, auto-increment and defaults — and get the correct CREATE TABLE syntax for your database.
- CSV & Excel to SQL — Paste CSV or Excel cells, or open an .xlsx file, and get ready-to-run CREATE TABLE and INSERT statements with correctly escaped values for your database.
- SQL to JSON, CSV & Excel — Paste a SQL dump or a few INSERT statements and get the rows back as JSON, CSV or an Excel workbook with one sheet per table.
- Excel to JSON — Open an .xlsx workbook or paste cells straight from Excel or Google Sheets and get clean JSON.