Page 1 of 1

Update a groupID for several distinct users selected from column of other table

Posted: 2019-03-01 10:19
by fbrano
Hi,
I'd like to do an update of field groupID in table membership_users for selection of users from other table where they are selected by command:
SELECT DISTINCT Schvalovatel1 FROM `role`,

my question is how to write an update command correctly:
UPDATE `membership_users` SET `groupID` = 5 WHERE `custom2` = SELECT DISTINCT Schvalovatel1 FROM `role`

Many thanks in advance.

Re: Update a groupID for several distinct users selected from column of other table

Posted: 2019-03-02 09:58
by pbottcher
Hi,
try using

UPDATE `membership_users` SET `groupID` = 5 WHERE `custom2` in ( SELECT DISTINCT Schvalovatel1 FROM `role`)