suriel
suriel

Reputation: 337

SQL: Delete from Table with View as source

I have table like this

table1
column1 column2 column3
-----------------------
11      12      13
21      22      23
31      32      33

and a View like this

view1
column1 column2 column3
-----------------------
11      12      13
31      32      33

How to delete rows from table1 that have a match in view1?

Upvotes: 1

Views: 401

Answers (1)

Sathiya
Sathiya

Reputation: 239

Try the below sql query:

DELETE Table_1
FROM    Table_1  INNER JOIN  View1 
ON Table_1.col1 = View1.col1  
WHERE   Table_1.col1=View1.col1  

First join the table and view using INNER JOIN, then based on the condition delete the row.

Upvotes: 1

Related Questions