List to SQL IN Clause

Paste a column of values from a spreadsheet or log and get a ready SQL IN (...) clause, quoted and escaped, with optional deduplication and NOT IN.

Use the tool

Why this tool exists

You have fifty order numbers in a spreadsheet and need to look them up in the database. Wrapping each in quotes, adding commas and escaping apostrophes by hand is slow and a stray quote spoils the whole query.

This tool takes a list, one per line or comma-separated, trims it, removes duplicates and builds the clause. It detects numbers and leaves them unquoted, or you can force quotes. A single quote inside a value is doubled the SQL way. Oracle limits an IN list to 1000 expressions, so an option splits long lists into several IN groups joined by OR, or AND for NOT IN. Review queries before running them on production data.

How to use it

  1. Paste your values, one per line or comma-separated.
  2. Enter the column name, and choose quoting, deduplication, trimming and NOT IN as needed.
  3. Copy the clause into your SQL query.

Frequently asked questions

How does it decide whether to quote values?

In auto mode, values are left bare only if every one looks like a number. A single non-numeric entry quotes the whole list. Use always or never to override.

How are apostrophes escaped?

By doubling them, so O'Brien becomes 'O''Brien'. That is the standard SQL way and works in PostgreSQL, MySQL, SQL Server and Oracle.

What does the Oracle option do?

Splits the list into groups of 1000 values, because Oracle rejects larger lists, and joins them with OR. With NOT IN the groups are joined with AND.

Can I get only the parenthesised list?

Yes. Leave the column name empty and the output is just (value1, value2, ...), which you can drop into your own query.