如果在Postgresql中通过表C连接到表A的表B中的行被删除,那么如何删除表A中的行?
CREATE FUNCTION delete_training() RETURNS trigger AS
$$
BEGIN
delete
from trainings
where id in (
select t.id
from roots
inner join dictionaries d on roots.dictionary_id = d.id
inner join trainings t on roots.training_id = t.id
where d.id = old.id);
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER trigger_delete_training
BEFORE DELETE
ON dictionaries
EXECUTE PROCEDURE delete_training();