A foreign key constraint fails

后端 未结 3 1089
抹茶落季
抹茶落季 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:47

    A foreign key constraint means that you one table doesn't accept inserts, updates or deletes that would 'break' the foreign key. This means, you can't update a EmpID if the new EmpID doesn't exist in the users. You can't add a new EmpID if it doesn't exist in the users table, etcetera. So to solve this issue, you need to make sure that the EmpID you're trying to add to table 'leave', first exists in table 'users'. Foreign keys can be a real powerful item, but can be a real pain too. Since the DB you're working on had foreign key constraints, I suggest you read on them a bit: http://en.wikipedia.org/wiki/Foreign_key

提交回复
热议问题