Marcos Eusebi
Marcos Eusebi

Reputation: 637

Insert row for X time

I have a problem:

How I can insert a row and delete it X time?

I think something like INSERT the value whit a time stamp and add a task to delete it.

But I don't have idea how to add MySQL task and if here is a better method.

Upvotes: 1

Views: 187

Answers (1)

jcho360
jcho360

Reputation: 3759

you need to use event scheduler from MySQL:

the basic about MySQL scheduler is:

CREATE EVENT myevent
    ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 HOUR
    DO
      UPDATE myschema.mytable SET mycol = mycol + 1;

Source: http://dev.mysql.com/doc/refman/5.1/en/create-event.html

tutorial: http://www.sitepoint.com/how-to-create-mysql-events/

Guide: http://dev.mysql.com/doc/refman/5.1/en/events.html

Upvotes: 1

Related Questions