This topic is locked
[SOLVED]

 Auto update foreign key in child table when master key is updated

3/21/2019 2:25:34 AM
PHPRunner General questions
T
Tayyab Ilyas author

Hi I would like to know if there is any option of Auto updating foreign key in child table when master key is updated

M
MikeT 3/21/2019

This should be handled at the database level (if at all). See "ON UPDATE CASCADE " or similar for your used database server.

My advice would also be that if this has to happen a lot, maybe use another primary key that can be stable.

admin 3/21/2019

You should not be changing primary key under any circumstances, it is a bad idea. For whatever reason you trying to do this - use another field like @Michael2 suggested.