Click here to Skip to main content
15,921,203 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello !

Can anyone help me with the Deleting Statement in MySql. I want to delete a Table with value ( 7 days from now ). As picture bellow:

<a href="http://i1137.photobucket.com/albums/n512/character_kute/ASP%20net%20MVC2/Question.jpg">http://i1137.photobucket.com/albums/n512/character_kute/ASP%20net%20MVC2/Question.jpg</a>
Posted

Run a MySql event as discussed here[^].
 
Share this answer
 
Comments
thatraja 20-Jun-11 10:44am    
My 5!, worked in mySql just average.
So, how can i use it in C#? can you give me a code sample more clearly about that?
 
Share this answer
 
Comments
Simon_Whale 20-Jun-11 10:21am    
Abhinav's solution was to create a batch job on the server, that would allow you to run a task in a given time period.
you need to use the dataadd function in a sql statement.

Mysql Date functions[^]

either use this in the delete statement as a sub query or delete in your application.
 
Share this answer
 
Can you give me a structure of Delete Statement>
 
Share this answer
 
I tried to test as:
SELECT * From news_content_temp where created = date_sub(curdate(),INTERVAL WEEKDAY(curdate()) +7 day);

==> It worked well

But I tried to delete as:
Delete From news_content_temp where created = date_sub(curdate(),INTERVAL WEEKDAY(curdate()) +7 day);

==> It did not Work?

Why????
 
Share this answer
 
Comments
Simon_Whale 20-Jun-11 17:33pm    
try this

DELETE
FROM news_content_temp
WHERE DATE(CURDATE()) = DATE(date_add(created, INTERVAL 7 DAY)) ;
No one help me, Please!? I am waiting about that
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900