SQL IN Clause Generator
About this tool
About SQL IN Clause Generator
Copy a column of IDs, emails or order numbers from a spreadsheet, a log or a ticket, paste it here, and get a ready-to-run WHERE condition such as id IN (10452, 10453, 10477). The generator splits on new lines, commas, semicolons or tabs, strips stray quotes around values, and removes duplicates so the list stays short. Auto quoting leaves a list of plain numbers unquoted and wraps everything else in single quotes, escaping apostrophes; values with leading zeros are quoted so 007 is not turned into 7. You can force quotes on or off, sort the values, write NOT IN, or put one value per line for easier reviewing. Long lists can be split into chunks joined with OR, which you need for Oracle (it rejects more than 1000 items in a single IN list) and which keeps very long queries readable elsewhere. SQL Server output uses N'…' strings. Your list is processed in your browser and never sent anywhere.
Built and maintained by Abhi JainUpdated
How to Build an IN Clause
- 1
Paste the values
Paste values into the left pane, one per line or separated by commas or tabs, or click Sample.
- 2
Set the options
Enter the column name, choose Quotes (Auto, Always, Never), the database, sort order and Chunk size.
- 3
Copy the clause
Copy the IN clause from the right pane and paste it into your WHERE condition.
SQL IN Clause Generator: questions and answers
Is there a limit on the number of values in an IN clause?
Oracle allows at most 1000 expressions per IN list and raises ORA-01795 above that. SQL Server, PostgreSQL and MySQL have no fixed item limit but are bounded by query size and parameter limits. Chunking with OR avoids the Oracle limit.
When should values be quoted?
Text, dates and IDs with leading zeros must be quoted. Numbers compared with a numeric column should not be. Auto mode quotes everything unless every value is a plain number.
How are apostrophes handled?
Single quotes inside a value are doubled, so O'Hara becomes 'O''Hara', which every major database reads correctly.
IN or a JOIN for a long list?
For a few hundred values IN is fine. For many thousands, loading the values into a temporary table and joining is usually faster and easier to maintain.
Related Tools
- SQL INSERT GeneratorType or paste rows into a grid and get INSERT statements for any major database.
- CSV to SQLTurn a CSV file into CREATE TABLE and INSERT statements for MySQL, PostgreSQL, SQLite or SQL Server.
- JSON to SQLConvert a JSON array of objects into CREATE TABLE and INSERT statements.
- CSV Viewer & EditorOpen, edit, sort, filter and search big CSV files like a spreadsheet, then export CSV, TSV or JSON.