What if inner join can also be used as a delete query for removing rows from one table matching with a standard column from both tables.
Syntax
DELETE target tables
FROM table1
INNER JOIN table2
ON table1.commonColumn= table2.commonColumn
WHERE condition
- Using this syntax, we can delete rows from more than one table.
Example
Let us take two tables, WorkEmployee and EmpJoinDetails.
DELETE WorkEmployee, EmpJoinDetails FROM WorkEmployee
INNER JOIN EmpJoinDetails ON WorkEmployee.cID=EmpJoinDetails.cID
WHERE WorkEmployee.cID = 104;
- We can see that using this query using the delete query in join matching the corresponding columns can delete that.
- Likewise, we can see that the cID from the matching specified ids has been removed.
Fri, 07/15/2022 - 14:23
Comments