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!

Removing records based on match from seperate table 2

Status
Not open for further replies.

Corr

ISP
Jan 7, 2003
48
US
Hello All,

Here's what I got. TableA contains A list of phone numbers with area codes as so "9545551212". TableB has a list of area codes like 954
561
305 and so on.

I need to compare the area code in TableA with the area codes in TableB and remove all records in A that match in B.

USING MICROSOFT SQL SERVER, and ACCESS

Thanks in advance,

John
Boca Raton, FL

John
Systems Manager
Boca Raton, FL
 
Try this:
Code:
Delete From A
From B b
  where left(phone, 3) = b.<area code column>
 
delete tableA
from tableA t1,
tableB t2
where substring(t1.col1, 1, 3) = t2.col1)

Regards,
AA
 
I got it now. I was trying it in access first and had some syntax issues, but both posts helped me and worked great on my SQL Server. Still new to me. Thanks alot.




John
Systems Manager
Boca Raton, FL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top