-- Using IN Clause
DELETE from table_name WHERE id IN (2,6,9,8);
-- The above query will delete rows which has values - 2,6,9,8 in id name column
-- Using Between Operator
DELETE FROM table_name WHERE id BETWEEN 20 AND 50;
In the code snippet, we want to delete rows of a column named id which has different values. We are using IN clause of SQL to delete them. The basic syntax will be as below.
DELETE from table_name WHERE column_name IN (value_1, value_2, ...);
To delete rows that do not contain specific column values. The syntax will be as below.
DELETE FROM table_name WHERE column_name NOT IN (value_1, value_2, ...);
DELETE FROM table_name
WHERE id BETWEEN 3 AND 30;
DELETE FROM table_name
WHERE id >= 10 AND id <= 30;
DELETE FROM table_name
WHERE id NOT IN (10, 11, 12);
0 Comments