The easy answer would be to combine both queries, directly, using subqueries (IN
). So, assuming the column on shipments is also called id (substitute it with the real name, if different):
SELECT *
FROM shipments
WHERE id IN ( SELECT DISTINCT id
FROM customers
WHERE country = 'Neverland')
It may be nice to learn a bit about JOIN
s, while those may seem more complicated at first, they may have in some cases a better query plan or logically less complex once you learn about those:
SELECT *
FROM shipments
JOIN customers
ON shipments.id = customers.id
WHERE shipments.country = 'Neverland'
(again, you may need to adapt it to the particular column names, and cardinality relation- show no duplicate shipments, etc.).