SQL query to mass delete users based on Biography data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaggy
    New Member
    • Aug 2006
    • 13

    SQL query to mass delete users based on Biography data

    I recently had a few hundred spam accounts registered on my board. The one common attribute among all the accounts is that they entered "Man" in the biography profile field. Is there a SQL query I could run that would delete all these accounts? The mass/prune users feature has a very limited search. Thank you.
  • Jake Bunce
    Senior Member
    • Dec 2000
    • 46598
    • 3.6.x

    #2
    If there is some common value within their user table records then you can query the table to set yourself up to prune by group, like this:



    The biography is stored in the joined userfield table and I don't have a query for that. If no one else here has a query for you then the people on www.vbulletin.org might be able to help.

    Comment

    • Riki
      New Member
      • Dec 2007
      • 9
      • 3.6.x

      #3
      If anyone could help us figure this out it would be greatly appreciated. I tried for hours and searched for many more. The best I could come up with is this

      Code:
      UPDATE 
          user 
      LEFT JOIN
          userfield
      ON
          user.userid = userfield.userid 
      SET 
          usergroupid = '25'
      WHERE
          userfield.field1 = 'man'
      which returns with this error
      Code:
      error number: 1054 
      error desc: Unknown column 'userfield.field1' in 'where clause'

      Comment

      • Lats
        Senior Member
        • Mar 2002
        • 3671

        #4
        The query looks fine and you should have a field1 in the userfield table.

        What do you get when you run this query...
        Code:
        SHOW COLUMNS FROM userfield
        Lats...

        Comment

        • Riki
          New Member
          • Dec 2007
          • 9
          • 3.6.x

          #5
          When I run that query I get what is shown in the attached image. (sorry I couldnt paste the text due to the formatting).

          I am able to run a basic query that lets me know there is over 1k users with biography man, I just cant seem to move them to the new banned usergroup.

          I appreciate the help
          Attached Files

          Comment

          • Lats
            Senior Member
            • Mar 2002
            • 3671

            #6
            Looks normal, I'm guessing you're running the query in the ACP?

            Try running it in phpmyadmin, or remove the vertical spacing from the query.
            Lats...

            Comment

            • Riki
              New Member
              • Dec 2007
              • 9
              • 3.6.x

              #7
              Thanks for the quick reply. Its encouraging to know it should be working.

              Something I havent told yet is I have the vb prefix on my database. This is exactly what I am putting in the query.

              Code:
              UPDATE vbuser LEFT JOIN vbuserfield ON user.userid = userfield.userid SET usergroupid = '25' WHERE userfield.field1 = 'man'
              I tried this in phpmyadmin and get the same error. Am I missing a prefix somewhere?

              Comment

              • Lats
                Senior Member
                • Mar 2002
                • 3671

                #8
                Originally posted by Riki
                Am I missing a prefix somewhere?
                One or two

                Try this...
                Code:
                UPDATE 
                 vbuser 
                LEFT JOIN 
                 vbuserfield 
                ON 
                 vbuser.userid = vbuserfield.userid 
                SET 
                 vbusergroupid = '25' 
                WHERE 
                 vbuserfield.field1 = 'man'
                Lats...

                Comment

                • Riki
                  New Member
                  • Dec 2007
                  • 9
                  • 3.6.x

                  #9
                  Thanks alot, for some reason it wont work for me if I use vbusergroupid, I have to leave it as usergroupid

                  here is the final code for anyone who wants it:
                  Code:
                  UPDATE 
                   vbuser 
                  LEFT JOIN 
                   vbuserfield 
                  ON 
                   vbuser.userid = vbuserfield.userid 
                  SET 
                   usergroupid = '25' 
                  WHERE 
                   vbuserfield.field1 = 'man'

                  Comment

                  • losedude
                    New Member
                    • Sep 2006
                    • 16
                    • 3.7.x

                    #10
                    Thanks, this solved my problem

                    Comment

                    • Rebirth
                      New Member
                      • Jan 2005
                      • 18
                      • 3.0.3

                      #11
                      I know this post is old, but I wanna thank you for this query and hope it can help more people. I got 11,000+ bot registrations with exactly the same custom profile set as '123456' and this helped tremendously.

                      Thank you!

                      Comment

                      • CRISTIAN C.
                        New Member
                        • Mar 2005
                        • 3
                        • 3.5.x

                        #12
                        Hope to help. For who using vbulletin 4, the command is more clean, no 'vb' in front of user, so:

                        UPDATE
                        user
                        LEFT JOIN
                        userfield
                        ON
                        user.userid = userfield.userid
                        SET
                        usergroupid = '12'
                        WHERE
                        userfield.field1 = 'man'

                        Change 'man' with anything else your spammer wrote in the profile field
                        Change '12' with your spamers usergroup.

                        Great people here, found what I need and finished with bot spam. Thanks!
                        CRISTIAN C. - BMWforum admin

                        Comment

                        • MusicMan
                          New Member
                          • Nov 2005
                          • 5
                          • 3.5.x

                          #13
                          Glad to see someone has found a way to fix this problem. I'm very thankful that these spammers/bots were considerate enough to use the same "Man" entry in the Biography field, but I couldn't figure out how to mass prune them all, until finding this thread. One question though...If I have some legitimate users with "man" somewhere in that field, such as a user with 2,000 posts whose biography is "Manager of yadda yadda", will it delete them as well? Or does the use of single apostrophes in the script above only target those whose fields are "man" and nothing else? I need a definitive answer to this, because the last thing I want to do is to prune legitimate users, especially very active ones.

                          Comment

                          • Lats
                            Senior Member
                            • Mar 2002
                            • 3671

                            #14
                            You don't need to worry there, the query as is will only match the whole field if it is equal to 'man'.

                            For info, if you wanted to match the Manager example the query would be "like '%man%".
                            Lats...

                            Comment

                            • MusicMan
                              New Member
                              • Nov 2005
                              • 5
                              • 3.5.x

                              #15
                              Originally posted by Lats
                              You don't need to worry there, the query as is will only match the whole field if it is equal to 'man'.

                              For info, if you wanted to match the Manager example the query would be "like '%man%".
                              Nice, thanks for the confirmation.
                              Last edited by MusicMan; Sat 7 Jan '12, 5:16pm.

                              Comment

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