Insert dates in MySql Workbench

12,450

One solution is to disable the foreign key check with SET FOREIGN_KEY_CHECKS:

SET FOREIGN_KEY_CHECKS=0;
INSERT INTO `myfacebook`.`mensajes` (`Codigo`, `NickUsuario`, `CodigoRedDest`, `Mensaje`, `Fecha`) 
VALUES ('7', 'MaGo', '1', 'M7', '2013-09-23')
SET FOREIGN_KEY_CHECKS=1;
Share:
12,450
jualsevi
Author by

jualsevi

Updated on June 04, 2022

Comments

  • jualsevi
    jualsevi almost 2 years

    I have a error when I try to insert dates with MySql Workbenck

    ERROR 1452: Cannot add or update a child row: a foreign key constraint fails (myfacebook.mensajes, CONSTRAINT CodigoRedDest FOREIGN KEY (Codigo) REFERENCES redessociales (Codigo) ON DELETE NO ACTION ON UPDATE NO ACTION)

    SQL statement:

    INSERT INTO `myfacebook`.`mensajes` (`Codigo`, `NickUsuario`, `CodigoRedDest`, `Mensaje`, `Fecha`) 
    VALUES ('7', 'MaGo', '1', 'M7', '2013-09-23')
    

    I'm beginner and I don't know what is the problem. If you need more dates about my tables, you say me.

    Thanks for your answers.