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