我应该删除所有订单少于100且居住在黑斯街的客户的所有条目。
由于应从3个表中删除:“客户”表,“订单中的物品”表和“订单”表
CREATE DATABASE dogsLife;
use dogsLife;
CREATE TABLE Items
(
ItemID int PRIMARY KEY,
ItemDesc varchar(35),
stock int,
cost double
);
CREATE TABLE Clients
(
clientID int PRIMARY KEY,
clientName varchar(35),
Street varchar(35)
);
CREATE TABLE Orders
(
OrdID int PRIMARY KEY,
clientID int,
OrderDate date,
FOREIGN KEY (clientID) references Clients(clientID)
);
CREATE TABLE Items_in_orders
(
OrdID int,
ItemID int,
quantity int,
FOREIGN KEY (OrdID) references Orders(OrdID),
FOREIGN KEY (ItemID) references Items(ItemID),
PRIMARY KEY (OrdID, ItemID)
);
INSERT INTO Items VALUES (1,'skirt',50,100),
(2,'dress',24,300),
(3,'shirt',55,250),
(4,'pants',2,400);
INSERT INTO Clients VALUES (123,'Or','Bilu'),
(345,'Sapir','Even Gvirol'),
(567,'Yael','Aza'),
(789,'Hila','Hess');
INSERT INTO Orders VALUES (2020,123,'2019-04-10'),
(2030,345,'2019-04-11'),
(2040,123,'2019-04-14'),
(2050,345,'2019-04-16'),
(2060,567,'2019-04-16'),
(2070,789,'2019-04-18');
INSERT INTO Items_in_orders VALUES(2020,1,200),
(2020,2,40),
(2020,3,60),
(2030,2,30),
(2030,4,1),
(2040,3,20),
(2050,1,40),
(2060,2,50),
(2070,1,1);