我有以下表格
vehicle (veh_num(PK), veh_desc)
log (log_num(PK), veh_num(FK), log_date, log_complaint)
log_line (log_num(PK,FK), logline_num(PK), emp_id(FK), logline_date,logline_action)
part (part_code(PK), logline_num(FK), log_num(FK), part_desc)
signout (signout_num(PK), part_code(FK), emp_id(FK), log_num(FK), signout_date)
我想运行一个查询,该查询将删除车辆表中的所有记录,例如 veh_num = "EK458" 并删除与其他表中的 veh_num 相关的行。
我从以下查询开始,
DELETE FROM signout WHERE EXISTS
(select * from vehicle,log,log_line,part
where
vehicle.veh_num = 'EK458' AND
vehicle.veh_num = log.veh_num AND
log.log_num = log_line.log_num AND
log_line.log_num = part.log_num AND
part.part_code = signout.part_code);
此查询删除了签出表中 veh_num = "EK458" 的所有关联值,但是,我想要一个查询,该查询将从与 veh_num 相关的所有表中删除行。提前致谢