Osensnolf Osensnolf - 4 months ago 5x
SQL Question

Delete Rows 1-150934 in SQL

I need to delete rows 1-150934 from my database.

Unfortunately, the ID's in this section are not 1-150934 (as they are shuffled) so I cannot match on that. The only thing I can go on is that I need to delete the first 150934 rows that appear in my table Listing_Summary.

Is this possible?

I have never ran a delete statement before. I looked on here and did not find a Where statement that would match was I was trying to do.



Use the LIMIT to limit the number of rows that are deleted:

    [PARTITION (partition_name,...)]
    [WHERE where_condition]
    [ORDER BY ...]
    [LIMIT row_count]

From MySQL reference manual:

The MySQL-specific LIMIT row_count clause for DELETE specifies the maximum number of rows to be deleted.

Edit: Do not use this command as-is, but you are going to want to do something similar to this:

DELETE FROM `Listing_Summary`
LIMIT 150934

You will need to update the ... in the WHERE clause and ORDER BY clause based on your particular use-case.