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
User avatar
fbrano
Veteran Member
Posts: 70
Joined: 2018-03-19 10:39
Location: Slovakia
Contact:

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.
ver 23.15 1484

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

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

Post by pbottcher » 2019-03-02 09:58

Hi,
try using

UPDATE `membership_users` SET `groupID` = 5 WHERE `custom2` in ( SELECT DISTINCT Schvalovatel1 FROM `role`)
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Post Reply