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 / May 2008

Tip: Looking for answers? Try searching our database.

Need help with my query for comparing two tables?!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
juvi - 30 May 2008 09:41 GMT
Hello,

thx for any help in advance. I have got this query for comparing two tables
for differences. It works fine, but which changes must I do to only get the
query result from table B? I know that only table B can have changes so I do
not need the records from table A.

SELECT ID, COL1, COL2, COL3 ... INTO tbl_diff
FROM
(
SELECT A.ID, A.COL1, A.COL2, A.COL3, ...
FROM A
UNION ALL
SELECT B.ID, B.COL1, B.COl2, B.COL3, ...
FROM B
) tmp
GROUP BY ID, COL1, COL2, COL3 ...
HAVING COUNT(*) = 1
ORDER BY ID
John Spencer - 30 May 2008 17:14 GMT
Perhaps the following will work for you.

SELECT * FROM TableB Into tbl_Diff
WHERE TableB.Id in
   (SELECT ID
    FROM
      (
       SELECT A.ID, A.COL1, A.COL2, A.COL3, ...
       FROM A
       UNION ALL
       SELECT B.ID, B.COL1, B.COl2, B.COL3, ...
       FROM B
       ) tmp
    GROUP BY ID, COL1, COL2, COL3 ...
    HAVING COUNT(*) = 1)

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County

> Hello,
>
[quoted text clipped - 15 lines]
> HAVING COUNT(*) = 1
> ORDER BY ID
 
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.