0

Within my database I have a large number of tables which contain dates, expiry dates to be precise.

Currently I perform the following commands to remove any rows which are older than a date using:

 DELETE FROM tablename WHERE DATE(datepoint) < '2019-03-12'

1) Is there a way I can instead search and delete from an entire database?

DELETE FROM database WHERE DATE(datepoint) < '2019-03-12' 

2) Following this, is there a automated script I could which does this action on a daily basis? Rather than manually?

Kind Regards,

Shyam

jarlh
  • 42,561
  • 8
  • 45
  • 63
croco88
  • 45
  • 4
  • Break (1) into parts -- you want to create a list of tables in each database, and then search each table. As for (2), you can write this yourself once you've done (1) `;-p` – Martin Mar 12 '19 at 10:28
  • You may need to check this [How to schedule a MySQL query?](https://stackoverflow.com/questions/9621355/how-to-schedule-a-mysql-query) – Olaitan Adeboye Mar 12 '19 at 10:34
  • I am still a bit unclear on this, is there any example code? – croco88 Mar 12 '19 at 16:31

0 Answers0