MySQL Delete From Inner Join

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.


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.


Let us take two tables, WorkEmployee and EmpJoinDetails.

delete mysql inner join

delete with inner join mysql

DELETE WorkEmployee, EmpJoinDetails FROM WorkEmployee  
INNER JOIN EmpJoinDetails ON WorkEmployee.cID=EmpJoinDetails.cID   
WHERE WorkEmployee.cID = 104;  

mysql delete inner join

delete con inner join mysql

  • 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
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.