A foreign key constraint fails

后端 未结 3 1090
抹茶落季
抹茶落季 2021-01-06 23:18

I am relatively new in php and mysql.The problem that i am facing while i inserting value in my leave table.My leave table containing following co

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-06 23:43

    Borniet, you helped me solve my similar problem.

    @OP - All I had to do to fix this was create a corresponding row in the table so that the foreign key would exist. E.g. Table 1 has column Name Table 2 has column friends_name, a foreign key tied to Name in table 1. I got this error because I was trying to insert a row into table 2, where the friends_name referenced a non existing Name in table 1. So I created the name and we're off to the races :).

提交回复
热议问题