Example 1
Return only products in selected categories
The Food row (Apple) is excluded because 'Food' is not in the list. This is equivalent to WHERE category = 'Electronics' OR category = 'Clothing' but easier to read and extend.
Source table data Rows loaded before the example query runs.
Setup
CREATE TABLE products (id INT, name VARCHAR(50), category VARCHAR(50));
INSERT INTO
products (id, name, category)
VALUES
(1, 'Keyboard', 'Electronics'),
(2, 'Mouse', 'Electronics'),
(3, 'Shirt', 'Clothing'),
(4, 'Apple', 'Food');Validated query Shared across supported engines.
SQL
SELECT
name,
category
FROM
products
WHERE
category IN ('Electronics', 'Clothing')
ORDER BY
id;Expected result Returned rows for the shared example.
| name | category |
|---|---|
| Keyboard | Electronics |
| Mouse | Electronics |
| Shirt | Clothing |
Output is identical across all engines.