Determine if a supplier supplies all products in a list
Assuming that idProduct, idSupplier
are unique*, here is a simple query:
SELECT 1
FROM SupplierCatalog
WHERE idProduct IN (10, 26, 40, 42, 50) AND idSupplier = 5
HAVING COUNT(*) = 5 -- this is the number of items in the above list
This returns 0 or 1 rows which is all you need to check in your code.
* If duplicates are allowed/present change to HAVING COUNT(DISTINCT idProduct) ...
SELECT idproduct
FROM SupplierCatalog
WHERE idProduct IN (10, 26, 40, 42, 50)
AND idSupplier = 5
GROUP BY idproduct
HAVING COUNT(*) = 5
0 rows is false and 1 row is true
You can remove the AND idSupplier = 5
and get all the suppliers