Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
913 views
in Technique[技术] by (71.8m points)

sql - Add value to a column each month in Mysql Data Base

is there a way to update automatically the values of a column in a table in Mysql DB with a predifined value and the update should occur each month.

The situation is that i want to update the column balance in the table employees adding 2.5 days each month to each employee and the total amount of days should be reset each two years for each employee.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Databases don't really work that way. They are meant for storing information. You can write triggers so if you update a row or insert then an event happens but other then that the data doesn't change

Something like this should be handled in the application logic. Creat a cron or other periodic job that will grab rows created on X date and update them


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...