MyBB Community Forums

Full Version: Quick MySQL Query needed
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A query that updates members in X group with x post count to y post count. Can someone help me?
Moved to code modifications as this does not qualify for general support.
UPDATE mybb_users SET mybb_usergroup = "x" where postcount >= "y";

I believe that's your query.
Quote:A query that updates members in X group with x post count to y post count. Can someone help me?

I guess you mean people with Y post count to Group X ? Or Update the people of Group X with X Posts to Group Y with Y posts?

Clarify please... before we give you any code.

regards
yes I believe the statement actually is
UPDATE `mybb_users` SET `usergroup` = "x" where `postcount` >= "y" and `usergroup` = "z";

where
x=the GroupID of the TARGET USERGROUP
y= the number of posts that is the limit
z= the GroupID of the USERGROUP from where the users are to be moved

Note that this will only move those people who have the group Z as their primary group and will not touch those that have the group X as a secondary group...

for that...the code would be something like (NOT TESTED)
UPDATE `mybb_users` SET `usergroup` = "x" where postcount >= "y" and `usergroup` = "z" and instr(`additionalgroups`, `x`) >0;
although this would make people that have Z only as an additional group suddenly change their primary group to X....
just a word of caution...

cheers,
Kimmo
KimmoToungue that's not enough.. he needs something automaticToungue im waiting until he clears his ideaToungue Rolleyes
zaher1988 Wrote:KimmoToungue that's not enough.. he needs something automaticToungue im waiting until he clears his ideaToungue Rolleyes

automatic? didn't say so in the original request...but oh well...
He didn't say anything about automatic Rolleyes
Hmm Toungue it is a common sense guys Toungue
I do often mini-massupdates in phpmyadmin or with the dbase admin-tools in MyBB, because I lack the experience of writing up a tool that would do it automatically

as a matter of fact, I've written multiple simple-queries like this that are called by opening a certain page..this will set a flag against a number of records based on pre-set criteria...this flag is then utilized in some other utility of mine (mass email). I do not need it automatic...or actually I don't even want it automatic.

cheers,
kimmo