削除条件に副問い合わせを使う
これまでの考え方の延長なので簡単です。
DELETE FROM Products WHERE ProductID NOT IN ( SELECT ProductID FROM Sales ) ;
相関副問い合わせも使えます。
DELETE FROM Products WHERE NOT EXISTS ( SELECT 'X' FROM Sales WHERE Sales.ProductID = Products.ProductID ) ;
これまでの考え方の延長なので簡単です。
DELETE FROM Products WHERE ProductID NOT IN ( SELECT ProductID FROM Sales ) ;
相関副問い合わせも使えます。
DELETE FROM Products WHERE NOT EXISTS ( SELECT 'X' FROM Sales WHERE Sales.ProductID = Products.ProductID ) ;