what I have to do is basiclly create 3 tables.
I have created the first two which are the following.
table 1
table 2
Table 3 has to be this
What you need is a FOREIGN KEY with a ON UPDATE CASCADE definition, like this:
create table table_3 (
user_id int(10) unsigned,
CONSTRAINT fk_tb_1_user_id FOREIGN KEY (user_id) REFERENCES table_1(user_id) ON UPDATE CASCADE
);
int(10) unsigned is a type I invented to exemplify, but it should match exactly the user_id column type in table_1.
But pay attention, for the FOREIGN KEY to work, every user_id in table_3 MUST exist in table_1, you will not be able to insert a user_id in table_3 if it doesn't exist in table_1.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.