I have three tables:
customers: id, name
transactions: id_customer, id_item
items: id, name
WHERE id IN (SELECT
WHERE id_item IN (SELECT
WHERE name = 'apple'))
Yes, it's definitely better to use a join in this case. Try this:
SELECT DISTINCT A.name FROM customers A INNER JOIN transactions B ON A.id = B.id_customer INNER JOIN items C ON B.id_item = C.id WHERE C.name = 'apple'
In this way, only customers who placed an order containing
'apple's will be shown.