Delete based on composite key from another table
Which DBMS is it? If it is in oralce then pairwise comparison should work.
DELETE FROM Table1
WHERE (Col1, Col2) IN
(SELECT Col1, Col2
FROM Table2)
If it is SQL server then Michael's solution should work.
This can be cleanly performed using JOIN
with your DELETE
:
DELETE a
FROM
Table1 a
JOIN Table2 b
ON a.Col1 = b.Col1
AND a.Col2 = b.Col2