Hi I want to create a MYSQL trigger that updates my users's table. My Scenario is this : I have users table in which there is a field called Balance. Each Reseller assgins balance to its users to: Yes or No. Now if the reseller sets the balance of users to Yes, then i store the current date and time into database into a field called Reset_date. Now i want to count from today 30 days and when 30 days are completed i want to update users's balance to No So from the day then balance has been set to yes, after 30 days balance should be reverted to No.
I Guess i should also be using CRON JOB for this, as i have multiple reseller and multiple users. So the reset data is different for each of them.
I mean for user1 the reset date is today and for another it maybe different so might be cron job be needed here. So please guide me on how to use this cron job as well.
Below is my Table Structure for Users and Resellers:
Reseller
Users
答案 0 :(得分:1)
Your assumption about using cron job is correct. You can run a corn job every midnight using the following format:
0 0 0 1/1 * ? *
In your job, you can check for records with dates which are 30 days old and is assigned YES. Then you can update this records and assign status to NO
答案 1 :(得分:1)
Trigger a cron job.
yes
to no
if date has exceeded 30 days.I have added following images , refer them
I have added a cron which runs once in a day. and in your server, it looks like this.