I have table1 with columns ( id, id_user ) and table2 with columns (id, username).
The users are registered in table2. So what I want is to insert the table2.id
of the new registered users in table1.id_user
.
我要问:
INSERT INTO table1 (id_user) SELECT id FROM table2;
但结果是:
例如,我在<代码>表1.id上:
id
1
2
3
新的用户在表2中登记table1.id
looks:
id
1
2
3
1
2
3
4
and it repeats all the data every time there is a new registered user. How can I fix this to only add the newly registered user?