Databases: INSERT ... SELECT MySQL Statement fails

Databases: INSERT ... SELECT MySQL Statement fails

by James Redhat -
Number of replies: 1
Hi,

could anyone please explain to me why

UPDATE IGNORE moodle.mdl_user, restore.mdl_user SET moodle.mdl_user.country = restore.mdl_user.country

actually fails to change all the values in the country column of the mdl_user table in the moodle database ?

In restore.mdl_user are the correct values, which i need, but this statement sets everything to NULL - why ?

I changed the country column, so that NULL is possible ( i had to ) .

Thanks in advance !
Average of ratings: -
In reply to James Redhat

Re: Databases: INSERT ... SELECT MySQL Statement fails

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You have not told it how the rows of moodle.mdl_user and restore.mdl_user are linked

UPDATE moodle.mdl_user, restore.mdl_user SET moodle.mdl_user.country = restore.mdl_user.country WHERE moodle.mdl_user.id = restore.mdl_user.id

Probably works.