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