Boneyard Tools

SQL IN Clause Builder

Paste a column of IDs, usernames or product codes and it becomes a ready SQL IN (...) clause, splitting on both newlines and commas. When every value is a plain number the list stays bare, otherwise each value is single-quoted and any embedded apostrophe is doubled so O'Brien becomes 'O''Brien'. Add an optional column name and you get a full user_id IN (...) fragment to drop straight into a WHERE clause.

How to build a SQL IN clause

  1. Paste your values into the Values box, one per line or comma separated.
  2. Optionally type a column name such as user_id into the Column field to prefix the clause.
  3. Choose a Numbers mode: Auto, Force numeric or Always quote (this menu is disabled while Force quote is on).
  4. Tick Force quote, Dedupe or Sort as needed to reshape the list.
  5. Copy the finished clause from the SQL IN clause output box into your query.

Examples

Names become a quoted list

alice
bob
carol
IN ('alice', 'bob', 'carol')

A pure number list stays unquoted

101
102
103
IN (101, 102, 103)

Apostrophes are escaped by doubling

O'Brien
alice
IN ('O''Brien', 'alice')

Frequently asked questions

When are values quoted versus left as numbers?

In the default Auto mode the whole list is inspected: if every value is a plain decimal number the list stays unquoted, otherwise every value is single-quoted as a string. One non-numeric value flips the entire list to quoted.

What do the Numbers modes and Force quote do?

Auto decides for you, Force numeric always leaves values bare, and Always quote always wraps them in quotes. The Force quote checkbox overrides the menu entirely and quotes everything, which is why it disables the Numbers dropdown.

How are single quotes inside values handled?

They are escaped the SQL-standard way by doubling them, so O'Brien becomes 'O''Brien'. That keeps the clause valid when you paste it into most databases without breaking out of the string literal.

Can it remove duplicates and sort the list?

Yes. Turn on Dedupe to drop repeated values while keeping the first occurrence, and Sort to order them. Number lists sort numerically, so 2 comes before 10, while text lists sort alphabetically.

How should I separate my values?

Use newlines, commas, or a mix of both. The builder splits on runs of newlines and commas together, trims whitespace around each value, and drops any empty entries, so messy pasted lists still come out clean.

Can I add the column name automatically?

Yes. Enter a column such as user_id in the Column field and the output becomes user_id IN (...). Leave it blank to get just the IN (...) fragment on its own.

Is this safe against SQL injection?

It escapes apostrophes for known, trusted lists such as IDs you already have, but it is not a substitute for parameterized queries. For values that come from untrusted user input, bind them as parameters instead of pasting them into a clause.

Which databases does the output work with?

The standard single-quote doubling works in PostgreSQL, SQLite, SQL Server and MySQL in default mode. If your MySQL session enables backslash escaping you may want to review string literals before running the query.

Is my data uploaded anywhere?

No. The clause is built entirely in your browser and nothing is sent to a server, so it is safe to use with sensitive IDs, emails and internal identifiers.

Learn more

Related tools