Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / February 2008

Tip: Looking for answers? Try searching our database.

delete record from table a if it matches record in table b

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
denise - 07 Feb 2008 15:58 GMT
I'm having trouble getting this to work:
delete A.* from A  where  exists(select * from A, B
where a.empno = b.a_empno and a.paycode = b.a_paycode and a.hours1 =
b.a_hours1 and a.date1 = b.a_date1 and a.pos = b.a_pos);
It has to match all fields in both tables not just one. This is giving me
all of them, not just the matches.
Thanks for any ideas.
John W. Vinson - 07 Feb 2008 18:03 GMT
>I'm having trouble getting this to work:
>delete A.* from A  where  exists(select * from A, B
[quoted text clipped - 3 lines]
>all of them, not just the matches.
>Thanks for any ideas.

If you create a unique Index on the combination of all five fields, then you
should be able to:

DELETE A.*
FROM A INNER JOIN B
ON  a.empno = b.a_empno and a.paycode = b.a_paycode
and a.hours1 = b.a_hours1 and a.date1 = b.a_date1 and a.pos = b.a_pos;

What are you trying to accomplish? I wonder if a UNION query or an Append
might be a better option!

            John W. Vinson [MVP]
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.