LB1234
asked on
Need to relate two tables via index and foreign key, but the other table already has data, how to resolve?
Getting: #1452 - cannot add or update a child row a foreign key constraint fails mysql
Need to relate two tables via index and foreign key, but the other table already has data so I'm getting the above error, how to resolve?
And could someone explain why it's a problem that there's data there already?
Need to relate two tables via index and foreign key, but the other table already has data so I'm getting the above error, how to resolve?
And could someone explain why it's a problem that there's data there already?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I have a cats_id autoincrementing in the cats table and a cats_id in the kennels table. A relationship has been created. When I enter a new cat in the cats table, it creates an autoincremented int in the cats table. In the kennel field, I would "1" to associate that cat with the kennel it was being kept in correct? If so, what if I had hundreds of cats? I'd have to look up the cats_id for each one before entering the number into the kennel? That can't be the case can it?!