SQL DELETE JOIN Example

Query to delete library entry for id 1001 using JOIN

Query:

DELETE library_books
FROM  library_books JOIN students ON
students.student_id =library_books.lib_id
WHERE lib_id= 1001 
SELECT * FROM library_books

Output:

SQL DELETE JOIN

DELETE JOIN in SQL lets you delete rows of a table, based on conditions involving another table. We can use the DELETE statement with the JOIN operation to perform DELETE JOIN.

We use JOIN to combine data from multiple tables., to delete the same rows or related rows from the table at that time we use delete join.

In this article let us see how to delete multiple data using DELETE using JOIN by using MSSQL as a server.

Similar Reads

Syntax

DELETE table1 FROM table1 JOIN table2 ON table1.attribute_name = table2.attribute_name WHERE condition...

Demo SQL Database

For this DELETE JOIN tutorial, we will use the following two tables in examples:...

SQL DELETE JOIN Example

Query to delete library entry for id 1001 using JOIN...

Key Takeaways about DELETE JOIN

DELETE JOIN allows to delete rows from a table based on condition involving another table.We can use DELETE with JOIN to delete multiple rows from two or more tables.Using WHERE clause with JOIN allows to specify condition for deleting rows.If a record is deleted from a table, related records in other table will be deleted too...

Contact Us