MySQL Forums
Forum List  »  Newbie

MYSQL Insert data problem
Posted by: Vaso Zonjic
Date: October 26, 2016 02:44AM

0
down vote
favorite

I have big problem. I have 2 related tables: Parent and Child which are related by primary and foireign key.

primary table:

CREATE TABLE project_main ( ProjectMainId int(11) NOT NULL, ProjectTitle varchar(150) DEFAULT NULL, ProjectShortTitle varchar(50) DEFAULT NULL, ProjectIntroduction text
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

child table:

CREATE TABLE project_detail ( ProjectDetailId int(11) NOT NULL, ProjectProtocolNumber int(11) DEFAULT NULL, ProjectNumberPatients int(11) DEFAULT NULL, ProjectNumberSites int(11) DEFAULT NULL ProjectMainId int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

When I try to insert data into Parent table MYSQK Says:

1452 - Cannot add or update a child row: a foreign key constraint fails (ctb_db.project_main, CONSTRAINT project_main_ibfk_1 FOREIGN KEY (ProjectMainId) REFERENCES project_detail (ProjectMainId))

This thing does not happened in MSSQL database :(

regards, Vasko

Options: ReplyQuote


Subject
Written By
Posted
MYSQL Insert data problem
October 26, 2016 02:44AM
October 26, 2016 04:32AM
October 26, 2016 09:53AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.