SQL IN Clause Generator

Paste IDs, emails or codes — one per line, comma-separated or straight from an Excel column — and get a ready-made WHERE … IN (…) clause.

Runs in your browserUpdated
Split on
Output
Quoting
Clean-up
Layout

Groups: 0 = no limit; use 1000 for Oracle.

Your data never leaves your computer. All processing happens 100% locally in your browser.

How to use the SQL IN Clause Generator

  1. Paste your values — copy a column from Excel or Google Sheets, or paste a comma-separated list.
  2. Choose the output form, column name and table, and whether to use NOT IN.
  3. Quoting is automatic: numbers stay unquoted, text is wrapped in single quotes with apostrophes escaped.
  4. 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

InputAuto 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 ServerN'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.

Frequently asked questions

How do I turn an Excel column into a SQL IN list?
Select the cells in the column, copy, and paste them into the Values pane. Each cell becomes one value, duplicates are removed and text is quoted automatically.
What is the maximum number of values in an IN clause?
Oracle allows 1,000 per list. Other databases have no hard limit but get slow with very long lists — use a temporary table or a join for tens of thousands of values.
Should numbers be quoted?
Not if the column is numeric. If the column is text (such as codes with leading zeros), quote them so the database compares strings and can use its index.
How do I find rows that are not in the list?
Tick NOT IN. Be careful: if the list contains NULL, NOT IN returns no rows in standard SQL.

Related tools