I am a new user. I would like to ask about an error I encountered in my homework project. I create room_type_id
which is the primary key in the room type table. room_type_id
is then included as a foreign key in the room table. The problem is if I enter one of the room type IDs as RI2 instead of RT2. When I try to change it in an update query in the room table it says Unable to update child row foreign key constraint failed. However, it shows that the parent row cannot be updated, the foreign key constraint in the room type table failed. I'm sorry about my English as it's not my main language
1 2 3 4 |
|
1 2 3 4 5 6 7 8 9 10 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
1 2 3 |
|
1 2 3 |
|
1 2 3 |
|
P粉0372155872024-02-26 16:08:09
The foreign key constraint failed because there is no row containing room_type_id='RT2'
in your room_type
table
Additionally, if a row in room
has a specific room_type_id
, that row cannot be changed in the room_type
table. To do this, you can perform the following steps:
room_type_id
in room_type
room
to get the new room_type_id
room_type_id
wrong row from room_type