[thelist] SQL: Deleting every row over 30
Lauri Vain
lauri_vain at tharapita.com
Mon Mar 11 15:25:00 CST 2002
Hi there,
We're doing a classified system and for each item category we have, what
the project manager calls "discussion pages". It basically operates in a
simple 'guestbook style' with the exception that only 30 newest posts
will be kept in the database (for each category). Older posts will be
deleted altogether.
Obviously, I can't do
"DELETE FROM as_discussion WHERE parent='7' LIMIT 30,5" (You can't use
two numbers in LIMIT in case of a DELETE)
So, what would be the best way to delete every row over 30 from the
database? Any good suggestions?
Thanks in advance!
For those interested, the DB layout:
--------- DUMP ---------
CREATE TABLE as_discussion (
id INT(11) NOT NULL auto_increment, /* Unique ID */
parent INT(11), /* Parent
category */
name text, /* Post author */
email text, /* E-mail of poster */
title varchar(200) default NULL, /* Post title */
body text, /* Body text */
dtime datetime default NULL, /* Time */
PRIMARY KEY (id),
UNIQUE KEY id(id)
) TYPE=MyISAM;
--------- DUMP ---------
Yours,
Lauri
--
Tharapita Creations
[dynamic web applications]
lauri.vain at tharapita.com
Mobile: +372 53 410 610
More information about the thelist
mailing list