top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to Delete a Table using Join?

0 votes
How to Delete a Table using Join?
posted Jul 18, 2014 by Karamjeet Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

Left Join fetches all rows of table1(left table) with matching rows of table2(right table). So we can delete using Left Join.
Delete employee_salary FROM employee_salary LEFT JOIN employee ON
WHERE employee.first_name='Admin';

answer Jul 22, 2014 by Rahul Mahajan
0 votes

We often use INNER JOIN or OTHER JOIN to select the data from one table and the corresponding data from another table. MYSQL allows you to use INNER JOIN clause with DELETE statement so that you can easily delete records from one table and also the corresponding records from another table.

DELETE zpost ,zcomment FROM zpost INNER JOIN zcomment ON zpost.zpostid = zcomment.zpostid WHERE condition

NOTE : IF you omit zpost table, it would delete records from zcomment. AND if you omit zcomment then it would delete records from zpost.


You often use LEFT JOIN clause in the SELECT statement to find records that exist in the left table and does not have corresponding records in the right table. You can also use the LEFT JOIN clause in the DELETE statement to delete record in a table (left table) that does not have corresponding record in another table (right table).

answer Aug 17, 2014 by anonymous
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.