Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Query Help 1

Status
Not open for further replies.

cdogstu99

MIS
Jan 17, 2005
68
US
I have two tables A and B each with common field "Policy No". I want to delete from B all records which are not in A, based on the policy number. Can someone show me how to do this? Thanks

 
Something like this ?
DELETE FROM B
WHERE [Policy No] Not In (SELECT [Policy No] FROM A);
Or this ?
DELETE B.* FROM B LEFT JOIN A ON B.[Policy No] = A.[Policy No]
WHERE A.[Policy No] Is Null;
Or this ?
DELETE FROM B
WHERE Not EXISTS (SELECT * FROM A WHERE A.[Policy No]=B.[Policy No]);

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top