Hello fellow DP members. I have some questions, you see, I'm not a guru at MySQL but I'd like to learn from the ones who are So here's the question, let's say I have a table called "accounts" with column "coins" on it. Now, I want to give my users a bonus amount of coins but don't know which query to run. For example, user1 has 100 coins under his account and I want to give him 10 extra coins which would sum up to 110 in total. What query can I run to do this job? Thanks in advance
Is the increase always 10 or 10% or does it vary by user? Also, do you want to update every user at once, or just one at a time?
You probably need to set up another table for transactions, and store the sum of transactions in the accounts table. Think about it like a checking account -- transactions are recorded in your check register. It all depends on how much detail you need to track. If you don't need to track each transaction, then you may need just an UPDATE query: UPDATE accounts SET accounts.coins=accounts.coins+10 WHERE accounts.id=?