Paste a column of IDs, emails or codes copied from Excel, a log or another query. You get a ready WHERE … IN (…) condition with quotes escaped, duplicates removed and long lists split for databases with limits.
Last updated:
Values in clause0
Duplicates removed0
Treated as—
IN lists0
Advertisement
Advertisement
How to use the SQL IN Clause Generator
Paste your values into the left box, one per line or separated by commas or tabs.
Type the column name (e.g. customer_id) and choose IN or NOT IN.
Pick the database so quoting and escaping match it, and set a maximum list size if it has a limit.
Check the options: remove duplicates, sort, strip existing quotes, or wrap the result in your own query.
Press Generate IN Clause, read any warnings, then copy the SQL or download it as a .sql file.
IN list syntax by database
Database
Text value
Identifier quoting
Notes
Standard SQL / SQLite
'O''Brien'
"order"
Double the single quote; double quotes mean a column or table name.
MySQL / MariaDB
'O''Brien', backslash doubled
`order`
Backslash is an escape character unless NO_BACKSLASH_ESCAPES is set.
PostgreSQL
'O''Brien'
"order"
Also accepts col = ANY (ARRAY[…]), handy with array parameters.
SQL Server
'O''Brien' or N'Ünïcode'
[order]
Use the N prefix for NVARCHAR columns with non-Latin text.
Oracle
'O''Brien'
"ORDER"
Maximum 1,000 values per list (ORA-01795); split longer lists.
Long lists, NULLs and other traps
Chunks are joined with OR for IN and with AND for NOT IN.id NOT IN (…) OR id NOT IN (…) would match almost every row, which is a classic bug when splitting lists by hand.
Leading zeros matter. ZIP codes, phone numbers and SKUs such as 00721 must stay quoted; as numbers they lose the zeros and stop matching.
Type mismatches slow queries down. Comparing a VARCHAR column with unquoted numbers (or a number column with quoted strings) can force a conversion on every row and skip the index. Match the quoting to the column type.
Duplicates are harmless but noisy. They do not change the result, but removing them keeps the statement shorter and easier to review.
Prefer parameters in application code. This tool is for ad-hoc queries, reports and scripts. In an application, pass the values as bound parameters or an array to avoid SQL injection.
Frequently asked questions
How do I turn an Excel column into a SQL IN list?
Copy the cells in Excel and paste them into the input box. Each cell arrives on its own line, so the tool splits on new lines, trims spaces, removes duplicates and wraps everything in an IN ( … ) list with the right quotes. Type your column name to get the full condition, for example customer_id IN (1001, 1002, 1003).
Should values in an IN clause be quoted?
Text values must be in single quotes, such as 'abc'. Numbers can be written without quotes when the column is numeric. Leave quotes on codes with leading zeros like 00721; unquoted they become the number 721. Auto-detect only drops the quotes when every value is a plain number without leading zeros.
How do I escape an apostrophe in a SQL string?
Standard SQL escapes a single quote by doubling it, so O'Brien becomes 'O''Brien'. That works in PostgreSQL, SQL Server, Oracle, SQLite and MySQL. MySQL also treats the backslash as an escape character by default, so the tool doubles backslashes when you choose MySQL. Double quotes are for identifiers in standard SQL, not for string values.
Is there a limit on the number of values in an IN list?
Oracle allows at most 1,000 expressions in one list and raises ORA-01795 above that. Other databases have no fixed number but are limited by statement length and parameter limits, and huge lists parse slowly. Set Max values per list to 1,000 and the tool splits the list into several IN lists joined with OR, which Oracle accepts.
Why does NOT IN return no rows when the list contains NULL?
x NOT IN (1, 2, NULL) means x <> 1 AND x <> 2 AND x <> NULL, and any comparison with NULL is unknown, so the whole condition is never true. Likewise IN (NULL) never matches NULL rows. With the NULL option on, the tool removes NULL from the list and adds an explicit IS NULL or IS NOT NULL test instead.
When should I use a temporary table instead of a long IN list?
For tens of thousands of values a join is usually faster and easier on the query planner: load the values into a temporary table (or a table-valued parameter in SQL Server, or = ANY with an array parameter in PostgreSQL) and join to it. IN lists are ideal for quick lookups, ad-hoc reports and a few hundred to a few thousand values.
Is my data sent to a server?
No. The list is processed by JavaScript in your browser, so customer IDs, emails and other values never leave your computer.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.