Question: command coming out wrong mysql> mysql> mysql> alter table songs add foreign key(artist_id) references artist(id); ERROR 1452 (23000): Cannot add or update a child row:

command coming out wrong

mysql> mysql> mysql> alter table songs add foreign key(artist_id) references artist(id); ERROR 1452 (23000): . Add 2 foreign key constraints to the songs table: artist_id and genre_id are the foreign keys. 15.1. You  

mysql> mysql> mysql> alter table songs add foreign key(artist_id) references artist(id); ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (music. #sql-5b_10, COM EFERENCES'artist' ('id')) mysql>

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

It looks like you are attempting to add a foreign key constraint to the songs table that references the id column in the artist table but youre encoun... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!