how to solve this problem (SQL Error (1452): Cannot add or update a child row: a foreign key constraint fails (`pendaftaran_prs`.`#sql-3fc_1`, CONSTRAINT `FK_kelas_murid` FOREIGN KEY (`ID_Murid`) REFE

farah posted 6 months ago in General

hello .... i am beginner HeidiSQL....Now i am doing my practical work for my exam ...it is about making system registration for my school's kokurikulum....

murid(ID_Murid<KP>,Nama_Murid,No.KP,Jantina,Tingkatan) kelas(ID_Kelas<KP>,Nama_Kelas)

and i have problem that i can't understand to do it....when i want to save my table kelas after i learning to do the relationship between table murid and table kelas and i want to make i want to make ID_Kelas as a Foreign Key for table murid ...after that,this sentence show up..

Cannot add or update a child row: a foreign key constraint fails (pendaftaran_prs.#sql-3fc_1, CONSTRAINT FK_kelas_murid FOREIGN KEY (ID_Murid) REFERENCES murid (ID_Murid))

1 attachment(s):
  • Picture1
ansgar posted 6 months ago

HeidiSQL probably warned you that the source and foreign column doesn't have exactly the same data type, didn't it?

However, the error mostly means exactly that - so check both the source and the target column definition.

Please login to leave a reply, or register at first.