Eissoj
Eissoj

Reputation: 11

MySQL Relations

I have multiple tables containing different data. Some fields exist in other tables and are related to eachother. How could I make it that if I update field A in table A the related field in table C automatically updates too?

Thanks in advance

Upvotes: 1

Views: 1214

Answers (1)

Conrad Frix
Conrad Frix

Reputation: 52645

You need to create or update the FK to Cascade the change

FOREIGN KEY (parent_id) REFERENCES parent(id)
                      ON UPDATE CASCADE

For more see the documentation on FOREIGN KEY Constraints

Upvotes: 5

Related Questions