Monday, 9 September 2013

delete rows from a table using MySQL Scheduler

delete rows from a table using MySQL Scheduler

I have a MySQL table called: "regkeys". This table has two columns:
"keyCat" and "keyNum". In my web-app I have a keygen module that adds a
key(1134fb) and a category(mds or dts, etc.) into this table.
What I want to accomplish is this: after issuing (adding into the db) a
key, I'd like to create a MySQL event to delete the keys that stay/stayed
in my table longer than 2 days(or so), this way expiring the keys (for
instance - from the time was created, counting 2 days, each key has to be
deleted, in this case I have certain keys that will get deleted later than
others, depending on when they were created). I looked at the MySQL's API,
but I need some help with the logic. I do not know how to tell the event
to delete only the keys that were stored in for 2 days (or so). I was
hoping somebody could give me a quick complete example.
Thank you very much in advance.

No comments:

Post a Comment