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

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
fbrano
Veteran Member
Posts: 33
Joined: 2018-03-19 10:39

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

Post by fbrano » 2019-03-01 10:19

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.

pböttcher
AppGini Super Hero
AppGini Super Hero
Posts: 608
Joined: 2018-04-01 10:12

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

Post by pböttcher » 2019-03-02 09:58

Hi,
try using

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

Post Reply