• 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

cmeinck

Well-known member
#1
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 (
)
 

Jake Bunce

XenForo moderator
Staff member
#2
Code:
UPDATE xf_user
SET user_state = 'moderated'
WHERE user_id BETWEEN 121 AND 167
The range is inclusive of the boundaries.
 

SchmitzIT

Well-known member
#4
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.