ERROR 1452: Cannot add or update a child row: a foreign key constraint fails

后端 未结 21 2014
野性不改
野性不改 2020-11-22 07:01

I have created tables in MySQL Workbench as shown below :

ORDRE table:

CREATE TABLE Ordre (
  OrdreID   INT NOT NULL,
  OrdreDato DA         


        
21条回答
  •  执念已碎
    2020-11-22 07:38

    When you're using foreign key, your order of columns should be same for insertion.

    For example, if you're adding (userid, password) in table1 from table2 then from table2 order should be same (userid, password) and not like (password,userid) where userid is foreign key in table2 of table1.

提交回复
热议问题