To make it remove just that secondary usergroup, try this:
Code:
UPDATE user
LEFT JOIN
userfield on (user.userid = userfield.userid)
SET user.membergroupids = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', user.membergroupids, ','), ',SECONDARYUSERGROUPID,', ','))
WHERE !FIND_IN_SET(userfield.fieldXXXX,'1,2,3')
To be sure that it works the way you want, make a test user that it would effect, then get that user's id and change
Code:
WHERE !FIND_IN_SET(userfield.fieldXXXX,'1,2,3')
to
Code:
WHERE !FIND_IN_SET(userfield.fieldXXXX,'1,2,3') AND user.userid = USERIDHERE
This way it will only effect that user and you can see if its working correctly :up: