I have two tables
Users:
user | name | country | rank | country_rank | points
1 | frank | US | to be determined | to be determined | to be determined
Awards:
awarded_to | points_awarded
1 | 10
1 | 30
How can I make a stored procedure to update the users total points
based off of the points
from awards
, then their rank
and country_rank
respectively based off of the order of the points
(i.e. rank
1 would be the user with the most points
)?
I considered making a PHP script and using a crontab to call it occasionally that would just select the info and do the math etc in PHP, but stored procedures seems much more practical for my use-case.