nathancording nathancording - 18 days ago 8
MySQL Question

Deleting a range in MySQL

I am working on a fairly large database (MySQL) with over 20,000 records and I need to delete a select few records. for example I deleted record 3106 and I need to delete 3107,3108,3207,3458,3414. I just don't know how to multi delete.

Example:

DELETE FROM `serial_codes` WHERE `serial_codes`.`SerialID` = 3106 LIMIT 1;

Answer

Use in function:

DELETE FROM `serial_codes` WHERE `serial_codes`.`SerialID` in (3106, 3107,...)

or OR

DELETE FROM `serial_codes` WHERE `serial_codes`.`SerialID` = 3106 or  `serial_codes`.`SerialID` = 3107 or ...