I am using MySQL and I would like a field in my table to be periodically incremented per month. I’m making a banking application and would like to give an interest rate for all the accounts… can anyone please advice me on how to get started or go about doing it?… thank you
2
Answers
You can use mysql scheduler to run it each month. You can find samples at
http://dev.mysql.com/doc/refman/5.1/en/create-event.html
First, ensure your table has a field to store the interest rate for each account.
Next, define a scheduled event using MySQL’s CREATE EVENT statement. This event will execute periodically to increment the interest rate field for all accounts. You can specify the interval at which the event should run, such as every month.
Within the event, write a SQL query to update the interest rate field for all accounts. This query should calculate the new interest rate based on the current rate and any applicable rules or formulas.
Enable the MySQL event scheduler if it’s not already enabled. You can do this by setting the event_scheduler variable to ON.