mysql - Delete data from two tables -


i wish delete data 2 tables have: staff, , staff_take_courses. sqlcommand line keeps giving error:

error 1451 (23000): cannot delete or update parent row: foreign key constraint fails (`exclusif`.`staff_take_courses`, constraint `fk_staff_has_courses_staff1` foreign key (`staff_id`) references `staff` (`id`) on delete no action o n update no action) 

here query:

  delete s, stc staff s inner join staff_take_courses stc on stc.staff_id = s.id s.id= '$id'; 

please me out

why can delete in 2 statement:

 delete staff_take_courses staff_take_courses.staff_id= '$id';  delete staff staff.id= '$id'; 

there must problem relationship between tables. not allowing delete tables