Hi there I'm setting up twp table that are linked with a foreign key.

members

customer_id (primary)
fobnumber ZERO FILLED
firstname
lastname
emailaddress
access_id (foreign)

userAccess

access_id (primary)
username
password

(engine: InnoDB)
I have created recreated these tables, when both tables seem to linked. Data will go in to one database but not the other. i get the following error:

#1452 - Cannot add or update a child row: a foreign key constraint fails

please help

Craig.

Recommended Answers

All 2 Replies

It means that you are trying to update a foreign access_id, which is not yet in the userAccess table.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.