How to delete multiple rows in SQL



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;



Comments

Popular posts from this blog

Android App Version Update using the following cordova cli commands

75 inspirational quotes that will change your life

Retrieval Image From DataBase and Display on WebPage by Using Servlets.