SQL IN Clause Generator

Paste a column of IDs, emails or codes and convert it to a comma separated list with single quotes, ready for a WHERE … IN query. The tool trims spaces, removes duplicates, escapes apostrophes and splits long lists into batches.

List to IN clause
values
Values found
–
In the list
–
Duplicates removed
–
IN groups
–

Runs entirely in your browser — nothing is uploaded. Duplicate checks are case-sensitive, so Apple and apple both stay. If you leave the batch size blank, the tool uses 1,000 values per list, the Oracle limit.

How to Convert a Column to a Comma Separated List with Single Quotes

Paste the column, leave Quotes on Auto or single quotes, and copy the result. Three rows reading apple, Banana and O’Brien come out as name IN (‘apple’, ‘Banana’, ‘O”Brien’): each value is trimmed, wrapped in single quotes, any apostrophe is doubled, and commas go between them.

  1. Copy the column from Excel, Google Sheets, a CSV or a log file.
  2. Paste it into Values and type a column name, such as name.
  3. Keep Quotes on Auto, or pick single quotes to force them on numbers too.
  4. Copy the output into your WHERE clause.

Behind the scenes it splits your paste into values, trims each one, strips quotes you already added, drops blanks and optional duplicates, then wraps and joins the rest.

Formula: values = paste split on the chosen separators, trimmed, blanks removed. In Auto mode, if every value matches a plain number (no leading zeros), the list is left bare; otherwise each value becomes ‘ + value with every ‘ doubled to ” + ‘. Output = column IN (v1, v2, …, vn). If n exceeds the batch size b, the list is cut into ceil(n ÷ b) groups joined with OR.

  • Values: paste from Excel, Google Sheets, a CSV or a log file.
  • Column name: added before IN; leave it blank to get only the bracketed list.
  • Quotes: Auto, always single quotes (for text keys), or none.
  • Split values on: choose New lines only when values contain commas, such as “Smith, Jane”.
  • Duplicates: remove or keep repeated values.
  • Max values per IN list: the batch size for databases with a list limit; if you leave it blank, the tool uses 1,000.

SQL WHERE IN List of Strings and Numbers: Examples

Strings get single quotes and plain numbers stay bare, as these inputs show.

InputSettingsOutput
1001, 1002, 1003, 1002, 1005Auto, column id, remove duplicatesid IN (1001, 1002, 1003, 1005) — 5 found, 1 removed
apple, Banana, O’BrienAuto, column namename IN (‘apple’, ‘Banana’, ‘O”Brien’)
007, 042Auto, column codecode IN (‘007’, ‘042’)
a, A, aAuto, no column, remove duplicates(‘a’, ‘A’)
2,500 numeric IDsAuto, column id, batch 1,0003 groups: (id IN (1,000 values) OR id IN (1,000 values) OR id IN (500 values))

Convert a Column to a Comma Separated List in Excel, Then Check It

Select the cells, copy, paste, and each Excel row becomes one value. Check that Values found matches the row count in your sheet before you run the query. To add quotes to a comma separated list you already have, paste that instead; commas split values too.

  • Keep codes like 007 as text. Auto mode quotes values with leading zeros so the database does not read them as the number 7.
  • The SQL IN clause limit in Oracle is 1,000 values per list (error ORA-01795), so keep the batch at 1,000 there.
  • The same output works for NOT IN, but a NULL inside NOT IN makes the whole condition return no rows.

Microsoft explains the syntax and the error you can hit with huge lists in its IN (Transact-SQL) reference for SQL Server.

Common questions about SQL IN lists

How do I convert a column to a comma separated list with single quotes?Paste the column into the Values box and set Quotes to single quotes (Auto does it for any text). Each row is trimmed, wrapped in quotes and joined with commas, so apple, Banana becomes (‘apple’, ‘Banana’).
How do I convert a column to a comma separated list from Excel?Select the cells in one column, copy them and paste them into the Values box. Each row becomes a value and blank cells are ignored. If a cell holds a comma inside the value, set Split values on to New lines only so it stays together.
How do I write a SQL WHERE IN list of strings?Put each string in single quotes and separate them with commas, for example status IN (‘paid’, ‘shipped’). A quote inside a value is doubled, so O’Brien becomes ‘O”Brien’, which every major database accepts.
What is the SQL IN clause limit in Oracle?Oracle allows 1,000 expressions in one IN list and throws ORA-01795 above that. Keep the batch size at 1,000 and the tool joins several IN lists with OR, which Oracle runs without the error.
Does the output work in SQL Server and MySQL?Yes. SQL Server, MySQL, PostgreSQL and SQLite all accept a single-quoted list in the same format. SQL Server has no fixed list limit, but many thousands of values can exhaust query resources, so a temporary table and a JOIN is safer for very large lists.
Can it make comma separated values without quotes?Yes. Choose No quotes to get a bare comma-separated list, which suits numeric IDs, and Auto does this already when every value is a plain number. Unquoted words in SQL are read as column names, so keep quotes on text.

Related Tools

The binary to decimal converter decodes bit fields, the subnet calculator for IP ranges helps when you filter network logs, and the data storage converter for table sizes turns bytes into MB and GB. Keep the SQL IN clause generator handy for your next ad hoc query.

Related Calculators