We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,605 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

1542 error in defining foreign key

HI GUYS ..

im trying to make foreign key relation between whishlist_tbl(foreign) table and account_tbl(primary key) table
both are integer data container

scenario

i have user deatail table that is account_tbl and whish list table i.e wishlist_tbl i want that when user make a wish book then he must be registerd one and he must have account id i.e ac_id in the account_tbl where any or every wish item user add in the wishlist_tbl table must have his ac_id link with account_tbl, but when i tried to make relationship between both table this error occurs

SQL message

Cannot add or update a child row: a foreign key constraint fails (birds_eye.<result 2 when explaining filename '#sql-1204_1'>, CONSTRAINT FK_wishlist_tbl FOREIGN KEY (ac_id) REFERENCES account_tbl (ac_id))

***can anyone guide me what m i doing wrong because i've no idea as i ve made other relation like the same in this data base too and they are fine btw this a cart database any sugestion would be appericiated do reply thank all
***

2
Contributors
4
Replies
1 Day
Discussion Span
9 Months Ago
Last Updated
6
Views
aabi
Newbie Poster
22 posts since Jul 2010
Reputation Points: 4
Solved Threads: 0
Skill Endorsements: 0

What database are you using?

pritaeas
Posting Prodigy
Moderator
9,543 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,495
Skill Endorsements: 98

mysql and tool is sqlyog

aabi
Newbie Poster
22 posts since Jul 2010
Reputation Points: 4
Solved Threads: 0
Skill Endorsements: 0

What query did you use?

pritaeas
Posting Prodigy
Moderator
9,543 posts since Jul 2006
Reputation Points: 1,194
Solved Threads: 1,495
Skill Endorsements: 98

i uses GUI that is SQLYOQ but the qurey pop up with error msg is:

alter tablebirds_eye.wishlist_tbladd constraintFK_wishlist_tbl_acFOREIGN KEY (ac_id) REFERENCESaccount(ac_id)

aabi
Newbie Poster
22 posts since Jul 2010
Reputation Points: 4
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.1005 seconds using 2.68MB