SQL IN Clause Generator

Paste a list of order IDs, phone numbers or email addresses, one per line or separated by commas, and get a ready WHERE column IN (...) clause. Text is quoted and escaped, numbers stay bare, duplicates are dropped, and very long lists can be split into OR-joined groups for databases with a limit.

Database

0 = no split. Oracle allows 1,000 per list. Needs a column.

4 values, 1 duplicates removed, quoted as text.

SQL generation runs in your browser. What you type never leaves this device.

Features

  • Takes a column pasted from Excel or Google Sheets, or a comma separated line

  • Quotes text and escapes apostrophes; leaves numbers unquoted when every value is a number

  • Keeps values with leading zeros, such as 007 or 0987654321, as quoted text

  • Removes duplicates and empty lines, and says how many were dropped

  • NOT IN, and splitting into groups of N values joined with OR

  • Optional ten values per line for readable queries

Everyday uses

Looking up a list from a sheet

Operations sends 300 AWB numbers in a sheet. Copy the column, paste it here and query their order status in one go.

Excluding test accounts

Build a NOT IN list of internal user IDs to leave out of a report.

Bulk updates

Write UPDATE ... WHERE id IN (...) for a list of records support has asked you to fix, and keep the list in the ticket.

Using IN lists well

Text or numbers

Compare like with like. If the column is VARCHAR, quote the values even when they look like numbers, or the database may convert every row and skip the index. Choose Text (always quoted) for such columns.

Very long lists

  • Oracle allows at most 1,000 expressions in one IN list; set Split every N values to 1000.
  • SQL Server and others accept more, but queries with tens of thousands of values parse slowly.
  • For very large lists, load the values into a temporary table and JOIN, or use = ANY(ARRAY[...]) in PostgreSQL.

NOT IN and NULL

If the list or a subquery contains NULL, NOT IN returns no rows at all. Lists from this tool never contain NULL, but keep it in mind with subqueries.

SQL IN Clause Generator - FAQ