I'm sorry, I would need to see it in front of me in order to make sense of it. I can definitely give you the query I THINK it should be, but I could be wrong.
Example:
Code:
UPDATE user
LEFT JOIN
userfield on (user.userid = userfield.userid)
SET user.membergroupids = ''
WHERE !FIND_IN_SET(userfield.fieldXXXX,'1,2,3')
That basically says
clear a user's secondary usergroups, if the user's fieldx is
not 1,2 or 3
Again, this is my guess as to what you want, so use at your own risk.