Delete Query :
Query to delete from one table select from two table
OR
Delete using Join or ROWID Concept
We come across scenarios where we have required filter condition based on join/Inner Query of two or more tables ,Here there are multiple ways to achieve the goal.
1)Use Primary/Unique ID Column
DELETE FROM table1 t1
WHERE t1.unique_column IN (SELECT t11.unique_column
FROM table1 t11, table2 t2
WHERE t11.unique_column.t2.unique_colum);
2)Use Rowid to delete
DELETE FROM table1 t1
WHERE t1.rowid IN (SELECT t11.rowid
FROM table1 t11, table2 t2
WHERE t11.unique_column.t2.unique_colum)
3)Delete Duplicates using ROWID
Query to delete Duplicate
DELETE table1 a
WHERE ROWID < (SELECT MAX (ROWID)
FROM table1 b
WHERE a.unique_id = b.unique_id)
Simple Delete :
DELETE FROM table_name
WHERE condition;
Comments
Post a Comment