I want to add two columns together and then update one of those columns with the new result for each row every 5 seconds. (I know, probably not very practical in real life but it's for science!)
So this is what I figured out so far:
In order to make the database update happen every 5 seconds, I would either have to run a CRON job or use mySQL's event creator (I decided to go with the mySQL one) link
mySQL has something called SUM but it's really hard to understand and many of the answers are really just answers without any explanation :/
I would also have to run an UPDATE on the previous query.
So my table would be this:
kingdom(table)
____________
kingdom_id(int) | kingdom_gold(int) | kingdom_gold_rate(int)
____________
The idea is that kingdom_gold(int) would add kingdom_gold_rate(int) every 5 seconds. So if kingdom_gold = 0 and kingdom_gold_rate = 10; after 5 seconds kingdom_gold would be updated to 10. 5 seconds later, 20 etc...
But this would have to apply to all rows in the kingdom table. I think I understand how mysql scheduled events work but as far as adding those two columns and then updating it for every row is really beyond my understanding and I'd like to ask you all to help me learn this. Thank you!