Thursday, June 16, 2016

Deleting records before a certain date in Mysql

Hi,

I was looking for a query to delete the records up to certain date from my MySql table. It's pretty simple. Here is the MySql table:



We have a Delete button in our web page. By clicking on it, it asks for the Date up to which user can delete the data. Once user select the date and clicks on it, we need to run the query to delete the data up to the selected date.



The query I used to delete the data based on the date is

DELETE FROM data WHERE date < '2016-06-15'

That's all. Happy Coding. Hope it helps.

No comments: