Multiple values

2 snippets in SQL

SQLSQL

IN Operator

SQL · Filtering
Syntax
WHERE column IN (value1, value2, ...)
Example
SELECT order_id, status
FROM orders
WHERE status IN ('pending', 'processing', 'shipped');
Output
-- Orders with any of the three listed statuses

Note IN is shorthand for multiple OR conditions. If the list contains a NULL, it will not match NULL rows - use IS NULL separately. You can also use a subquery inside IN.

INSERT Multiple Rows

SQL · Data Modification
Syntax
INSERT INTO table (col1, col2)
VALUES (val1, val2), (val3, val4), ...;
Example
INSERT INTO products (product_name, price, category_id)
VALUES
  ('Wireless Mouse', 29.99, 2),
  ('USB Keyboard', 49.99, 2),
  ('27" Monitor', 349.00, 3);
Output
-- 3 rows inserted

Note Multi-row INSERT is much faster than individual INSERTs because it reduces round trips and allows batch optimization. Most databases support this syntax. There may be a limit on the number of rows per statement.

Frequently asked questions

How does SQL handle multiple values?
SQL covers this with 2 copy-ready snippets on this page. The "IN Operator" snippet in SQL uses `WHERE column IN (value1, value2, ...)`.
Which statement does the SQL example use?
The "IN Operator" snippet uses `WHERE column IN (value1, value2, ...)`, from the Filtering section of the SQL cheat sheet.
What other SQL snippets are shown for "multiple values"?
Besides "IN Operator", this page also shows "INSERT Multiple Rows".
Is there anything to watch out for?
Yes. For "IN Operator": IN is shorthand for multiple OR conditions. If the list contains a NULL, it will not match NULL rows - use IS NULL separately. You can also use a subquery inside IN.