0

I am getting this error while inserting in my table:

A Database Error Occurred
Error Number: 1452

Cannot add or update a child row: a foreign key constraint fails (`giftme`.`giftme_shop`, CONSTRAINT `shop_ibfk_2` FOREIGN KEY (`sh_cid`) REFERENCES `giftme_shop_category` (`sc_cid`) ON DELETE CASCADE)

INSERT INTO `giftme_shop` (`sh_uid`, `sh_shop_name`, `sh_cid`) VALUES ('79', 'Naveen Reddys shop', 1)

Filename: /var/www/apps/helpers/sessions_helper.php

Line Number: 55

1 Answer 1

3

there is foreign key reference

parent : `giftme_shop_category`.`sc_cid`
child : `giftme_shop`.sh_cid

there is no value of sc_cid=1 in parent table

Remove Foreign Key constraint

ALTER TABLE giftme_shop DROP FOREIGN KEY shop_ibfk_2;

read here

http://dev.mysql.com/doc/refman/5.5/en/innodb-foreign-key-constraints.html

 ALTER TABLE tbl_name DROP FOREIGN KEY fk_symbol
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.