2011-10-04, 03:04 PM
the problem with all the queries so far is that they remove the users from any additional groups they may already be in. adding and removing a user from group directly in mysql should be a two query process.
to add a specific user to an additional group and save any additional groups
AND
to add a user that is not already in an additional group
THEN
to remove a specific user from an addiitonal group and keep all other additional groups
AND
remove a user from the specific group
us "IN"
to add a specific user to an additional group and save any additional groups
update mybb_users set additionalgroups = CONCAT(additionalgroups, ',X') where username = "someuser" and additonalgroups != ""
AND
to add a user that is not already in an additional group
update mybb_users set additionalgroups = 'X' where username = "someuser" and additonalgroups = ""
THEN
to remove a specific user from an addiitonal group and keep all other additional groups
update mybb_users set additionalgroups = REPLACE(',X', '', additionalgroups) where username = "someuser" and additonalgroups LIKE '%,%'
AND
remove a user from the specific group
update mybb_users set additionalgroups = '' where username = "someuser" and additonalgroups = 'X'
(2011-10-04, 02:54 PM)Shemo Wrote: [ -> ]perfect, that worked! geez, if I just tried that originally, it would of work. now that that is worked out, when I want to do more than 1 username at once, would I write it like this?
UPDATE `mybb_users` SET `additionalgroups` = '' WHERE `username` = 'guy','guy2','guy3';
us "IN"
UPDATE `mybb_users` SET `additionalgroups` = '' WHERE `username` IN ('guy','guy2','guy3');