Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Wählen Sie alle Kunden aus, es sei denn, sie haben ein anderes Produkt – SQL

SELECT * FROM Customer C
LEFT JOIN Product PT ON C.CustID = PT.CustID AND PT.Item = 'Toaster'
LEFT JOIN Product PB ON C.CustID = PB.CustID AND PB.Item = 'Breadbox'
WHERE PT.Item IS NOT NULL AND PB.Item IS NULL