Mladen G
Mladen G

Reputation: 63

How to substract Table1 values from Table2?

Table1 contains ColumnA, Table2 contains ColumnA and ColumnB.

How do I remove(delete) rows in Table2 that contain ColumnA values in both tables?

Upvotes: 1

Views: 46

Answers (2)

PSK
PSK

Reputation: 17943

Another approach using EXISTS

delete t
from table2 t
where exists
(
 select 1 from table1 t1 where t1.columna=t.columna
)

Upvotes: 2

jarlh
jarlh

Reputation: 44796

Delete rows from table2 where the ColumnA value is also found in table1:

delete from table2
where ColumnA in (select ColumnA from table1)

Upvotes: 2

Related Questions