SQL Using IN clause with a subquery


Example

SELECT * 
FROM customers 
WHERE id IN (
    SELECT DISTINCT customer_id 
    FROM orders
);

The above will give you all the customers that have orders in the system.