
|
View Full Version : Help with simply mysql query please
lexington 09-19-2005, 07:31 AM Hello, here is a query that pulls up the results for all of the users on my forum with 50000 points:
SELECT *
FROM `phpbb_users`
WHERE `user_points` =50000
LIMIT 0 , 30
Could you please give me a mysql command that will find all users with 50000 points and reset only those users to 0 points? Thanks
maxymizer 09-19-2005, 07:35 AM UPDATE phpbb_users SET user_points = '0' WHERE user_points = '50000'
lexington 09-19-2005, 07:37 AM Thanks a lot, how do you learn this info without having to read 20000 pages of mysql basics tutorials?
PlanetWebHost 09-19-2005, 07:45 AM ummm, maxymizer's query will reset the points back to zero when they hit 50,000, that doesn't sound like what you wanted.
SELECT * FROM phpbb_users WHERE user_points = 50000
lexington 09-19-2005, 07:49 AM I already ran the command, so how do I undo it?
lexington 09-19-2005, 07:51 AM I just tested it and I was able to go past 50000 again
PlanetWebHost 09-19-2005, 07:55 AM Originally posted by lexington
I already ran the command, so how do I undo it?
Well, I wouldn't worry too much about that, it would only have reset that for someone that had exactly 50,000 points, what I would do is take a quick look and see if there's anyone with zero points that you know are active members.
SELECT * FROM phpbb_users WHERE user_points = 0
And, on the 50,000 thing? are you just trying to find the people that have more than 50,000 points in phpmyadmin? or are you scripting something to happen when someone reaches 50,000?
if you just want to see who has 50,000 or more points, then do this....
SELECT * FROM phpbb_uses WHERE user_points => 50000
lexington 09-19-2005, 07:58 AM Thanks, actually his first command worked. I wanted it to find all users with exactly 50,000 points and reset it back to 0, and it did just that.
maxymizer 09-19-2005, 08:28 AM PlanetWebHost, you didn't read what was asked in the topic..
Could you please give me a mysql command that will find all users with 50000 points and reset only those users to 0 points?
ummm, maxymizer's query will reset the points back to zero when they hit 50,000, that doesn't sound like what you wanted.
And answer to this question:
Thanks a lot, how do you learn this info without having to read 20000 pages of mysql basics tutorials?
SQL is actually very similar to "human" language. You are stating what you want to do and with which limitations.
In this case, you said "I want to find users with 50 000 points and reset them to 0".
Basically, SQL used for that operation was very similar to what you said - it was "Hey MySQL, please go and update my users and reset points to 0 for each user that's got EXACTLY 50 000 points".
You of course need to know some SQL keywords to issue queries.
Those are INSERT INTO, UPDATE, DELETE, SELECT - most basic ones (which you seem to be familliar with).
Regarding others - that's where you have to read the manual and follow examples :)
lexington 09-19-2005, 08:33 AM Regarding others - that's where you have to read the manual and follow examples
There is never a shortcut ;) Thanks :)
|