Forum Moderators: coopster
But table2 only has some of the usernames, not others. I want to find out which ones, and insert them all into table2.
Could anyone recommend a snippet of code that would do this? I think it might involve joining both tables, then finding out which do not match?
many thanks
INSERT INTO table2
(username)
SELECT table1.username
FROM table1
LEFT JOIN table2 ON table1.username = table2.username
WHERE table2.username IS NULL
;
NSERT INTO g2( username,wave )
VALUES username,id
SELECT users_1.username
FROM users_1
LEFT JOIN g2 ON users_1.username = g2.username
WHERE g2.username IS NULL
INSERT INTO g2
(username, wave)
SELECT
users_1.username,
users_1.id
FROM users_1
LEFT JOIN g2 ON users_1.username = g2.username
WHERE g2.username IS NULL
;
do you know a good tutorial on joins?
Here are a couple of basics that may be helpful:
LEFT JOIN [webmasterworld.com]
INNER JOIN [webmasterworld.com]