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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete rows from TABLE-A that do not match TABLE-B

Status
Not open for further replies.

ronwmon

Programmer
Jul 13, 2007
97
US
I have a situation where I need to delete rows from TABLE-A. I have another table (TABLE-B) that contains a list of ID numbers that match some of the rows in the TABLE-A. I need to delete all rows in TABLE-A that do not match TABLE-B. The common field name in both tables is site_no.

Any ideas on the best way to accomplish this?

Thanks,

Ron--
 
Dunno about it being the best way but here is one way.

DELETE FROM [table-a]
FROM [table-a] ta LEFT JOIN [table-b] tb ON
ta.site_no = tb.site_no WHERE tb.site_no IS NULL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top