#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0

    Deleting a range of rows from a table


    Hi all, I could not find this answer in my searches, I apologize if it has been answered previously.

    I am very new to SQL. I am looking for a query to delete a range of rows from a single table. There are MANY rows (200k+ ), and the solutions I have found are all for one row at a time like below:

    DELETE FROM post
    WHERE postid=237910


    DELETE FROM post
    WHERE postid=237911


    DELETE FROM post
    WHERE postid=237912


    all the way to:


    DELETE FROM post
    WHERE postid=470433


    Ideas? Better methodologies?

    TYIA!
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    Originally Posted by lexierowsell
    ...the solutions I have found are all for one row at a time
    let me guess, you never got past the w3schools tutorial

    Code:
    DELETE 
      FROM post
     WHERE postid BETWEEN 237910 AND 470433
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    Thank you, much appreciated.

    I got a few different answers from google, but I didnt find this.

    Thanks again, and apologies for being a twit.
  6. #4
  7. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    Originally Posted by lexierowsell
    Thanks again, and apologies for being a twit.
    you're welcome, and there is certainly no need to apologize

    you should see some of the sql i tried when i was just starting out
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    6
    Rep Power
    0
    I wish I could! I would love to have someone to learn from. I'm pretty sure I have jumped into the deep end my first round...

    Can always count on a fellow Canadian to lend a hand! (I'm a Bluenoser, Nova Scotia through and through, though currently displaced in Texas...)
  10. #6
  11. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    Originally Posted by lexierowsell
    Can always count on a fellow Canadian to lend a hand!
    that's fer sure, y'all
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo