A joined result can still be filtered. The WHERE condition can reference either table.

Program

Play the query to keep only high-value customer orders.

join_filter.sql
CREATE TABLE customers (id INTEGER, name TEXT);
CREATE TABLE orders (id INTEGER, customer_id INTEGER, total INTEGER);
INSERT INTO customers VALUES (1, 'Ada'), (2, 'Lin');
INSERT INTO orders VALUES (101, 1, 30), (102, 2, 12), (103, 1, 8);
SELECT customers.name, orders.total FROM customers JOIN orders ON customers.id = orders.customer_id WHERE orders.total >= 20 ORDER BY orders.total DESC;
join filter `WHERE orders.total >= 20` filters the joined rows.
DESC `ORDER BY ... DESC` sorts high values first.
composition Joins, filters, and sorting compose in one query.