No announcement yet.

Query to remove a specific secondary membergroup?

  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #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.


    • #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.


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