Home All Groups Group Topic Archive Search About

Deleting matching records

Author
15 Dec 2005 5:20 PM
Mir Khan
I need your help in MS Access…

There are 2 tables Table A with 50 records and Table B with 5 records
(similar records), I want to delete the 5 records of table B from Table A so
that in the end Table A should have 45 records (assuming all 5 records of
Table B are in Table A)…

Please help me…

Author
15 Dec 2005 5:28 PM
David Portas
Mir Khan wrote:
> I need your help in MS Access...

.... but this is a SQL Server group!

>
> There are 2 tables Table A with 50 records and Table B with 5 records
> (similar records), I want to delete the 5 records of table B from Table A so
> that in the end Table A should have 45 records (assuming all 5 records of
> Table B are in Table A)...
>
> Please help me...


In SQL Server:

DELETE FROM A
WHERE EXISTS
  (SELECT *
   FROM B
   WHERE B.col1 = A.col
    AND B.col2 = A.col2
    AND ... etc ) ;

--
David Portas
SQL Server MVP
--

AddThis Social Bookmark Button