1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Using mySQL to set range of user ids as moderated

Discussion in 'XenForo Questions and Support' started by cmeinck, Oct 6, 2012.

  1. cmeinck

    cmeinck Well-Known Member

    My intention here is to mass delete a range of users who spammed my forum, before running XenSSO to sync with my master forum. Found this recommendation online.

    I'm using this last suggestion as the method. First, I need a bit of help with mySQL range. He provides this query. How would I modify this to set a range of users from say user ID number 121 to user ID number 167. It's much more than that, but that's the general idea of what I'm trying to accomplish.

    Code:
    UPDATE xf_user
    SET user_state = 'moderated'
    WHERE user_id in (
    )
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    UPDATE xf_user
    SET user_state = 'moderated'
    WHERE user_id BETWEEN 121 AND 167
    The range is inclusive of the boundaries.
     
  3. cmeinck

    cmeinck Well-Known Member

    This worked perfectly. Thanks!
     
  4. SchmitzIT

    SchmitzIT Well-Known Member

    As an explanation, BETWEEN removes everything within the range. If you would only be interested in removing some specific ids, IN would be best.

    It'd then be:

    Code:
    UPDATE xf_user
    SET user_state = 'moderated'
    WHERE user_id in (121, 122, 123, 125, 126, 128
    )
    
    Notice it leaves out 124 and 127, which are the users you do want to keep. Alternatively, you could use multiple BETWEEN statements in such cases.
     

Share This Page