I need some help with the following in SQL:
I have 3 tables which have the following data:
table name:customer
customer ID - 1,2,3,4,5,6
customer Name - customer 1, customer 2,customer 3, customer 4, customer 5, customer 6
table name: transactions
Transaction ID -1, 2,3,4,5,6,7,8
Product ID - 2,2,3,4,2,1,4,2
customer ID - 1,2,4,4,5,6,2,5
table name: product
Product ID - 1,2,3,4
product Name - product 1, product 2, product 3, product 4
I want to know which customer(s) bought product 3 and 4 - the result should be just the customer with an ID of 4.
I have the lines below, however it will only work for 3 OR 4 due to the IN function which means displays customer ID 4 and customer ID 2. I am not sure where to use the AND function in this scenario
select distinct c.customer ID
, c.customer Name
FROM transactions t
LEFT
JOIN customer c
on c.customer ID = t.customer ID
LEFT
JOIN product p
on p.product ID = t.product ID
where p.product ID IN (3,4)`
Thanks
Vishal