Search code examples
mysqlsqlmariadbmysql-event

Perform delete a perticular records after some interval of time in mysql


DROP EVENT `deleteTestEntries`;
CREATE DEFINER=`root`@`localhost` EVENT `deleteTestEntries`
    ON SCHEDULE EVERY 1 MINUTE
    STARTS '2018-05-25 18:17:01'
    ON COMPLETION NOT PRESERVE ENABLE DO
    DELETE FROM lead_master WHERE lead_master.lname LIKE '%Test%'

What is wrong in above event. It has been created with no errors but not performing any action. I simply want to delete the records from my lead_master table where lname is 'Test'


Solution

  • I finally did it with cron jobs. I created a controller which calls a model function contains query to delete record. and set the cron job which calls the controller after specific interval of time.