Re: how to delete records older than 14 days
DELETE FROM news WHERE newsdate=DATE_ADD(CURRENT_DATE, INTERVAL -14 DAY) Above is the code that I would use to do that job. Hope this helps. -Angela Thomas Katsampes wrote: Hello, I'm trying to figure out the correct syntax for requesting the database to remove all records older than 14 days. The mysql query that I am using (from within php4) is: //---update news so only last two weeks of news are available---// $sql2 = "delete from news where newsdate DATE_SUB(NOW(), INTERVAL 14 DAY)"; $result2 = mysql_db_query($dbname,$sql); But it doesn't seem to be working. Here is the the definition of the "news" table: mysql describe news; +--+--+--+-+-++ | Field| Type | Null | Key | Default | Extra | +--+--+--+-+-++ | id | int(3) | | PRI | 0 | auto_increment | | hub | char(3) | YES | | NULL || | newsdate | date | YES | | NULL || | headline | varchar(100) | YES | | NULL || | article | longtext | YES | | NULL || +--+--+--+-+-++ 5 rows in set (0.05 sec) Basically this is for a news page, and items get pushed down the "list" (what the viewer sees) and then eventually are supposed to be deleted. Any suggestions on how to do this more efficiently would be welcome as well. Please email me directly (hit reply to the message). Thanks- Thomas - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: how to delete records older than 14 days
Sir, your DELETE statement runs fine on my computer. The problem appears to be in your PHP code. Post the problem to a PHP group with all the relevant lines, not just the two shown below. Hello, I'm trying to figure out the correct syntax for requesting the database to remove all records older than 14 days. The mysql query that I am using (from within php4) is: //---update news so only last two weeks of news are available---// $sql2 = "delete from news where newsdate DATE_SUB(NOW(), INTERVAL 14 DAY)"; $result2 = mysql_db_query($dbname,$sql); But it doesn't seem to be working. Here is the the definition of the "news" table: mysql describe news; +--+--+--+-+-++ | Field| Type | Null | Key | Default | Extra | +--+--+--+-+-++ | id | int(3) | | PRI | 0 | auto_increment | | hub | char(3) | YES | | NULL || | newsdate | date | YES | | NULL || | headline | varchar(100) | YES | | NULL || | article | longtext | YES | | NULL || +--+--+--+-+-++ 5 rows in set (0.05 sec) Basically this is for a news page, and items get pushed down the "list" (what the viewer sees) and then eventually are supposed to be deleted. Any suggestions on how to do this more efficiently would be welcome as well. Please email me directly (hit reply to the message). Thanks- Thomas - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php Know thyself? Absurd direction! Bubbles bear no introspection. -Khushhal Khan Khatak - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: how to delete records older than 14 days
On Sat, Jan 27, 2001 at 09:58:23AM -0600, Thomas Katsampes wrote: Hello, I'm trying to figure out the correct syntax for requesting the database to remove all records older than 14 days. The mysql query that I am using (from within php4) is: //---update news so only last two weeks of news are available---// $sql2 = "delete from news where newsdate DATE_SUB(NOW(), INTERVAL 14 DAY)"; $result2 = mysql_db_query($dbname,$sql); Uh.. is this an *exact* quote of your PHP script? Why are you defining $sql2, and using $sql in the mysql_db_query()? G'luck, Peter -- If I had finished this sentence, - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php