customer表:
orders表:
orders_items表:
order_items表中没有和customer表相同的列,本来是不能JOIN的,但是可以通过先把customer和order先JOIN一下,就可以和orders_items JOIN了
SELECT distinct customer_id,first_name,last_name
FROM customers
JOIN orders using(customer_id)
JOIN order_items using(order_id)
WHERE product_id = 3;