SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot zeeshan's Avatar
    Join Date
    Mar 2001
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to delete X number of rows in mySQL

    Hi all,

    I have a table with three fields: name, password, textstr. This table has grown to about 4500 rows, and I need to delete the FIRST 3000 rows. (and leave the last, latest 1500 in the table).

    I am using phpMyAdmin and want to know if there's a script/query I can write for this that will do this automatically instead of me having to manually click on 3000 Delete buttons!?!?!?!

    Any help would be appreciated.

    Thanks.

  2. #2
    SitePoint Addict AbelaJohnB's Avatar
    Join Date
    Oct 2001
    Location
    Eureka, CA. USA
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am guessing you have used a KEY (maybe something like: ID), and if so, than just run the following command:




    DELETE FROM table_name WHERE ID BETWEEN 1 AND 2999



    You can do that from within phpMyAdmin



    Later
    Last edited by AbelaJohnB; Nov 30, 2001 at 22:02.
    John B. Abela
    www.JohnAbela.Com

  3. #3
    SitePoint Zealot zeeshan's Avatar
    Join Date
    Mar 2001
    Posts
    123
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok bad news --- I have no ID key assigned.

    Any other way??? Can't I just POP out the first 1000 or something e..g like u can pop stuff from an array when programming?

    Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •