I'm not able to update a table with the select of another.
I have a mdl_user
table that contains several columns and created another users_sg
to copy some columns.
I copied with
INSERT INTO
users_sg (id, username, firstname, lastname)
SELECT
id, username, firstname, lastname FROM mdl_user
I wanted to stay updated, but I only managed to do one column and one user at a time:
UPDATE
users_sg
SET
users_sg.username = (SELECT username FROM mdl_user where id=3)
WHERE id=3
How do I update the username
, firstname
, and lastname
fields of all users at once?