1
MS-2001
a sql thing
  • 2004/12/14 18:25

  • MS-2001

  • Quite a regular

  • Posts: 204

  • Since: 2004/7/27


i want to delete all private messages a user recived but not the latest five.

*turn-on-creativity-mode*

DELETE FROM `xoops_priv_msgs` WHERE to_userid=1 ORDER BY msg_id ASC LIMIT COUNT(*) - 5

*turn-off-creativity-mode*

but it's not working *g*. so is there a possibility to do it within one statement?

2
MS-2001
Re: a sql thing
  • 2004/12/15 17:46

  • MS-2001

  • Quite a regular

  • Posts: 204

  • Since: 2004/7/27


any ideas?

3
Dave_L
Re: a sql thing
  • 2004/12/15 18:42

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I don't think it's possible to do that with a single query, except maybe with the subquery feature available in MySQL 4.1+.

If you're running MySQL < 4.1, you could do one query to determine the maximum msg_id to delete, and then do a second query to perform the deletion. Or you could write a PHP script to do it.

I'm also not sure whether it's safe to remove private messages simply by deleting them from the table. It probably is, but I'd check the existing script that deletes PMs to make sure there isn't any other cleanup involved.

Login

Who's Online

492 user(s) are online (57 user(s) are browsing Support Forums)


Members: 0


Guests: 492


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Sep 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits