I want to create an Event for Table :-
ACCOUNTS(id char(5),balance decimal(10,2), date_created date)
Value for the DATE_CREATED column will always be = NOW(), i.e. the date when the row was inserted in the table
I want that the balance for each row gets increased by 2% after every 31 Days, according to its DATE_CREATED column, i.e. after (DATE_CREATED+31 Days) for each row.
I wanted to know whether it is possible or not and if it is possible then what would be the code for it?
You’ll need to write an
UPDATEstatement that usesDATEDIFFandMODTry something like:
And here is the SQL Fiddle.
You can schedule this to run daily. That’s probably your best approach.
Good luck.