简体   繁体   中英

MySQL Error, what does it mean

I am trying to update two columns in a xref database. I am getting this error message:

Cannot add or update a child row: a foreign key constraint fails (`globaldetroit`.`org_cult_xref`, CONSTRAINT `org_cult_xref_ibfk_1` FOREIGN KEY (`org_id`) REFERENCES `organization` (`org_id`) ON DELETE CASCADE ON UPDATE CASCADE)

I want to be able to have a many-many relationship, and these errors seem to prevent me from having one.

EDIT:

That is very odd! There most certainly is a column org_id with the value of "6" (as an integer) in the table organization! I just checked!

You are trying to set a value that has a foreign key constrant -- ie the key does not exist in the foreign table.

So globaldetroit's org_cult_xref references an org_id in organization that does not exist.

you're putting in field globaldetroit . org_cult_xref value not existing in organization . org_id

Many-many relationship is bad, don't go there.

Your error seems to be caused because the row you insert in org_cult_xref has a column org_id and the value you insert there cannot be found in the organization table.

您在要插入/更新到的表上定义了一个外键,这基本上说org_id的值应该存在于organization表中,事实并非如此。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM