Query to remove a specific secondary membergroup?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GearTripper
    Senior Member
    • Aug 2004
    • 440

    Query to remove a specific secondary membergroup?

    Query to remove a specific secondary membergroup from a specific usergroup; I'm thinking...

    UPDATE user
    REMOVE membergroupids = 'x'
    WHERE usergroupid = x

    Would that be correct?
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    UPDATE user
    SET membergroupids = ''
    WHERE usergroupid = X

    This will remove all secondary group memberships for members of usergroupid X (primary group). I don't have a query to remove a single secondary group membership when the user belongs to multiple secondary groups.

    Comment

    • Andreas
      Senior Member
      • Feb 2004
      • 2323

      #3
      UPDATE user
      SET membergroupids = TRIM(BOTH ',' FROM REPLACE(CONCAT(',', membergroupids, ','), ',Y,', ','))
      WHERE usergroupid = X

      What does this query do?
      First of all, it adds a comma to the beginning and the end of membergroupids.
      Afterwards, it removes ,Y,
      In the final step it removes the commas added by step 1

      *No Guarantee*
      Last edited by Andreas; Tue 23 Jun '09, 4:27am.

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...