1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Mass remove rows from a table

Discussion in 'Databases' started by sawz, Mar 18, 2007.

  1. #1
    is there a query i can use to remove a large number of rows from a database i have? using php myadmin.
     
    sawz, Mar 18, 2007 IP
  2. ThreeGuineaWatch

    ThreeGuineaWatch Well-Known Member

    Messages:
    1,489
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Which rows? You'll need a condition to select which rows you wish to drop.
     
    ThreeGuineaWatch, Mar 18, 2007 IP
  3. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #3
    this table has 90,851 rows.

    i want to remove all rows from row number 88633 to the end.
     
    sawz, Mar 18, 2007 IP
  4. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #4
    i guess i'm all set. here is the query:
    DELETE FROM tablename WHERE id >1;
     
    sawz, Mar 18, 2007 IP
  5. ThreeGuineaWatch

    ThreeGuineaWatch Well-Known Member

    Messages:
    1,489
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    140
    #5
    That will wipe the lot.

    If you have an auto_increment'd field called id and you want to remove all the lines where id is equal to 88633 to the end of the table, then:

    DELETE FROM tableName WHERE id > 88632;
    Code (markup):
    will do it.

    Sounds like you might want to ensure you have the DB backed up before doing it.
     
    ThreeGuineaWatch, Mar 18, 2007 IP
  6. sawz

    sawz Prominent Member

    Messages:
    8,225
    Likes Received:
    808
    Best Answers:
    0
    Trophy Points:
    360
    #6
    no it won't. it will remove exactly what i want removed and it did.
     
    sawz, Mar 18, 2007 IP
  7. Lavee

    Lavee Well-Known Member

    Messages:
    234
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #7
    delete from tablename

    will just work fine

    Thanks

    Lavee
     
    Lavee, Mar 18, 2007 IP