in reply to CGI Program To Delete Old Data From MySQL Table?

It is also a good practice to wrap such things in BEGIN TRANSACTION / COMMIT or ROLLBACK ... not only because it's usually more-efficient that way, but also so that it is "cleanly all-or-nothing." Either the delete succeeds, completely, or it never happened at all. You can also test your work by starting a transaction, running the query, checking the result, and either (looks good!) COMMIT or (oops!) ROLLBACK.
  • Comment on Re: CGI Program To Delete Old Data From MySQL Table?

Replies are listed 'Best First'.
Re^2: CGI Program To Delete Old Data From MySQL Table?
by Jenda (Abbot) on Oct 02, 2013 at 09:26 UTC

    Just keep in mind that while you are checking the result, all those rows are locked. What exactly does that mean depends on the database and the table locking hints of other queries, but you may easily block everyone else!

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.

Re^2: CGI Program To Delete Old Data From MySQL Table?
by Anonymous Monk on Sep 30, 2013 at 18:54 UTC
    Note: requires InnoDB storage-engine in MySQL.