我有 3 个表,它们是多对多关系。IE:
Create Table Product(ProductId number(18,0) NOT NULL);
Create Table Customer(CustomerId number(18,0) NOT NULL);
Create Table CustomerProduct(CustomerId number(18,0) NOT NULL,ProductId number(18,0) NOT NULL);
由于 CustomerProduct 表同时引用 Product 和 Customer 表。我正在尝试从 CustomerProduct 表中删除数据。
我只能找到类似的东西:
DELETE FROM
(
SElECT CustomerProduct.* FROM CustomerProduct
INNER JOIN Product ON Product.ProductId = CustomerProduct.ProductId
INNER JOIN Customer ON Customer.CustomerId = CustomerProduct.CustomerId
WHERE Product.ProductId = 1 AND Customer.CustomerId = 7
);
注意:外键上没有定义 CASCADE 删除... Oracle 不允许我做我可以在 SQL SERVER 中做的事情
DELETE A
FROM A
INNER JOIN B on a.Id = b.id
WHERE b.Id = 2.....