Newbie here using W3schools demo database to practice SQL queries and I'm stuck on one:
SELECT Customers.CustomerID, Customers.CustomerName, Orders.OrderID, OrderDetails.ProductID, Products.ProductName FROM Customers
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID
INNER JOIN OrderDetails ON OrderDetails.OrderID = Orders.OrderID
INNER JOIN Products ON Products.ProductID = OrderDetails.ProductID
WHERE OrderDetails.ProductID <> 70
I want to see a list of customers who have made an order, but have not ordered product ID 70.
This query still shows the other orders of customer's who have ordered product ID 70. If a customer has ordered it, I don't want to see any of their other orders on this list. Does this scenario call for a subquery using WHERE EXISTS?
Thanks!