MySQL Forums
Forum List  »  German

Re: delete with inner join doesnt work
Posted by: Peter Brawley
Date: April 21, 2019 10:48AM

Yes that's exactly what On Delete Cascade means ...

drop table if exists c,p;
create table p( pid int primary key );
create table c (
  cid int primary key, 
  pid int, 
  foreign key(pid) references p(pid) on delete cascade on update cascade
);
insert into p values(1),(2),(3),(4);
insert into c values(1,1),(2,2);
select * from p left join c using(pid);
delete p,c from p join c using(pid) where p.pid=2;
select * from p left join c using(pid);

InnoDB now auto-maintains a FK index.

Options: ReplyQuote


Subject
Views
Written By
Posted
882
April 20, 2019 12:08PM
Re: delete with inner join doesnt work
405
April 21, 2019 10:48AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.