Toolstia / SQL IN clause generator

SQL IN clause generator

Paste a column of IDs or names and get a correct IN clause. Text is quoted safely, numbers stay bare, duplicates can be removed and long lists can be split for databases with a limit.

Single quotes inside values are doubled. Some databases, such as Oracle, limit an IN list to 1000 items, so set the chunk size to 1000 to split the list into groups joined with OR. Always review SQL before running it, and use parameters in application code.

How it works

  1. Paste your values, one per line or separated by commas.
  2. Set the column name and quoting.
  3. Copy the clause.

Quoting

By default text is wrapped in single quotes with any quote inside doubled, and plain numbers stay unquoted. You can also force or disable quotes.

Long lists

Oracle allows at most 1000 items in one IN list. Set the chunk size to 1000 to get several IN groups joined with OR (or AND for NOT IN).

NOT IN

Switch it on to exclude the values instead. Remember that NOT IN returns nothing if the list contains a NULL.

Safety

Use query parameters in application code. This tool is for ad hoc queries and reports.

Questions

Does it work for every database?

The output is standard SQL and works in MySQL, PostgreSQL, SQL Server, SQLite and Oracle.

Can it write the whole query?

It writes the IN clause with your column name. Add SELECT and FROM yourself.

Is my data stored?

Everything happens in your browser, and nothing you enter is sent anywhere.