Adding a TRIGGER to phpMyAdmin MySQL table to DELETE a row in Table A it's corresponding row is deleted in Table B -


so have 2 tables, reservations , reservation details.

the primary key reservationid reservationsis foreign key in reservation details.

in website, user can delete reservation reservation table.

how can add trigger if reservationid deleted reservation table row corresponding reservationid in reservation details deleted?

using phpmyadmin.

if want unconditionally delete reservation_details when delete parent row in reservations, can define on delete cascade on foreign key. definition reservation_details this:

create table reservation_details (     reservationdetailid int,     reservationid int,     -- etc...      foreign key (reservationid)         references reservations(reservationid)         on delete cascade ); 

see mysql documentation further details.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -