Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 5 of 5
  1. #1
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    I'm certainly not a MySQL syntax wiz, so I have to ask here:

    What is the MySQL "DROP" statement to DROP all the old items, and keep only the 200 newest?

    Thanks

  2.  

  3. #2
    Senior Member jlgosse's Avatar
    Join Date
    Jan 2004
    Location
    Newfoundland, Canada
    Posts
    1,037
    Member #
    4570
    Liked
    7 times
    I don't know if there is one, can you remove more than one row at a time?

    If you can't, just do it with PHP.


  4. #3
    Senior Member toadeny's Avatar
    Join Date
    May 2003
    Location
    Wellington, New Zealand
    Posts
    188
    Member #
    1426
    may be truncate with a limit if its possible ?

  5. #4
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    I haven't tried this as I'm far away from my computer.
    If your entries have an auto_increment column, then I guess the newest entries will have the highest 'ID' number. If you run a SELECT query for id with ORDER descending, a limit clause of 1 and an offset of 200, you will get the ID number for the entry 200 clicks down from your newest. Then you can use that number to delete entries older than that.

    (DELETE FROM table_name WHERE id < the_extracted_number_here)

    That would delete all entries older than the latest 200.


    If you want a more specific multidelete option, you could use Transio's multi-delete code. (In WDF's tutorials section)
    S. Rosland

  6. #5
    Senior Member
    Join Date
    Dec 2003
    Posts
    1,274
    Member #
    4362
    Thanks to all
    Finally I did it like this:
    Code:
    DELETE * FROM ajl_lastplayed ORDER BY started_at DESC LIMIT 199,18446744073709551615


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:10 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com