I have a table called Orders which consists of columns CUSTNUM, PRODNUM, DATE and QTY.
I am trying to retrieve the customers who ordered both products 3737 and products 9193 (particular values)
So I tried the following code with no success:
SELECT CUSTNUM
FROM ORDERS
WHERE PRODNUM = 9193
INTERSECT
(SELECT CUSTNUM
FROM ORDERS
WHERE PRODNUM = 3737);
After further reading also on this forum, I also tried this:
SELECT DISTINCT CUSTNUM
FROM ORDERS
WHERE PRODNUM IN (
select PRODNUM FROM ORDERS WHERE PRODNUM = 3737
) AND PRODNUM IN (
Select PRODNUM FROM ORDERS WHERE PRODNUM = 2357
);
The INTERSECT operator seems not to work although it is included in our textbooks.
I've also consulted INTERSECT in MySQL