How to delete multiple rows in SQL where id = (x to y)
If you need to delete based on a list, you can use IN:
delete from your_table
where id in (value1, value2, ...);
If you need to delete based on the result of a query, you can also use IN:
delete from your_table
where id in (select aColumn from ...);
(Notice that the subquery must return only one column)
If you need to delete based on a range of values, either you use BETWEEN or you use inequalities:
delete from your_table
where id between bottom_value and top_value;
or
delete from your_table
where id >= a_value and id <= another_value;
No comments:
Post a Comment