1

I have three tables in mysql database with the name of adduser, academic_record and admission , all tables have same column name std_id same date type, both tables academic_record and admission is linked with foreign key the column of std_id on adduser.

Now when i delete data from adduser, i found error that cannot be add or deleted... foreign constraint add.. can any one give me the solution I use this query for foreign key

alter table academic_record
add foregn key constraint fk_peracademic_record
where academic_record(std_id)
references adduser(std_id);
Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121
  • You have to delete the rows on `academic_record` and `ambition` that relates to that user before you can remove the user. See here: http://stackoverflow.com/questions/1905470/cannot-delete-or-update-a-parent-row-a-foreign-key-constraint-fails – uri2x Sep 05 '15 at 07:13

1 Answers1

0

Assuming that I have understood your question correctly, (you want to delete the records from the other tables when a record in the adduser tables is deleted, what you need is to add the ON DELETE CASCADE option.

e4c5
  • 52,766
  • 11
  • 101
  • 134