Filter rows based on results from another query.
Section: Subqueries
Use a subquery in WHERE
sql
sql
SELECT *
FROM products
WHERE category_id IN (
SELECT category_id
FROM categories
WHERE is_active = TRUE
);Explanation
Subqueries are useful when one query determines the filter set for another.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Subqueries