954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to create a mysql JOB

Hi everyone,

I have made a script which logs the users ip into a table.
Here is the table:

ID - PKEY A.INC
IP - VARCHAR
ENTERED - TIMESTAMP


What I would like to happen is that after a row has been inserted, I want to set up a sql JOB, to automatically tjeck this table for rows which are >= 24 hours old, and if found, then delete the row.

Or if it is easier to create: If time is 00.00 then delete all records in the table, that could support my idea too :-)

It is for a voting system on a website.

The only thing is, that I have never been near creating a JOB in SQL, I have just stuck to SELECT, UPDATE, DELETE statements.

It is the very last thing I need for finishing my exam project, and I hope someone can be helpful.

Regards Klemme

klemme
Posting Whiz in Training
265 posts since Mar 2011
Reputation Points: 18
Solved Threads: 7
 

If you want to do this after an insert, see the manual on TRIGGERS , otherwise see EVENTS .

pritaeas
Posting Expert
Moderator
5,480 posts since Jul 2006
Reputation Points: 653
Solved Threads: 875
 

Thanks pritaeas I will look into your links posted :-)

It not not after an insert, no user-action should be required for the deletion to happen.

So I suppose it should be an event, scheduled to run everyday at i.e. 00.00.

klemme
Posting Whiz in Training
265 posts since Mar 2011
Reputation Points: 18
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: