I have two tables: users
and pics
. They both have a pic_id
attribute except the pics
table references the pic_id
in the users
table.
Inside my users table: user_id: 15 password: test age: 18 pic_id: 0
I am trying to insert a row into my pics
table with the pic_id
attribute equal to the pic_id
value for user 15.
I am trying to do all of this in PHPMyAdmin and I am getting the Cannot add or update a child row: a foreign key constraint fails
error.
I read that the reason this error happens is because the value the referencing table is looking for does not exist; however in my case I am sure it does.
Attached is my users
and pics
table relationship: 1
EDIT: Constraint Properties:
CONSTRAINT `pics_ibfk_1`
FOREIGN KEY (`pic_id`)
REFERENCES `db`.`users` (`pic_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)