Question

I am trying to create foreign key for my database. My database is for a gym system.

I have the table called user. Within that table I have user_id which is my primary key. I have another table call member within this table I also have user_id which I want to make a foreign key so it relates to my user_id within the user table.

But i keep getting the following error..

#1452 - Cannot add or update a child row: a foreign key constraint fails (Gym_System.#sql-247a_3c1, CONSTRAINT #sql-247a_3c1_ibfk_1 FOREIGN KEY (user_id) REFERENCES members (user_id))

Can anyone help?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top