SQL IN list formatter
Processed in your browser · nothing is uploaded
Turns a pasted column of values into a SQL `IN (…)` list, quoting them only if they are not all numbers, and optionally wrapping the whole thing in `column IN (…)`.
How to use the sql in list formatter
This is the most common five-second task in a database console: someone sends a list of IDs in a message and you need them in a query. Doing it by hand means adding a comma to every line and quotes to some of them, which is exactly the sort of task that produces a syntax error on the third attempt. Quoting is decided by looking at the values: if every one is a number the list is left bare, so an integer column matches; if any is not, all are quoted. That is safer than mixing, because a quoted number still matches an integer column in most databases while an unquoted string is a syntax error. One limit worth knowing before you paste ten thousand rows: Oracle refuses more than 1,000 items in an IN list outright, and SQL Server and PostgreSQL will accept far more but plan the query badly. Past a few hundred values, loading them into a temporary table and joining is both faster and legal everywhere.
Questions
If every value is a number, none are. If any is not, all are — mixing is what causes syntax errors.