Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread SQL Question
Tue, Feb 12 2008 1:41 PMPermanent Link

"Nowhere"
I would like to know how to do the following

I want  to compare 2 identical structured tables and  create a result
set of just those records  where there is data difference in 1 or more
of the fields held in each record (I assume this would mean both
records need to be included so I could identify both values  although
it might be handy just to have the contents of 1 of the tables as
another choice)

I was told that the following UNION construct works but this is not
DBISAM


SELECT * FROM ( SELECT ID, USERNAME,EMAIL FROM KEYS UNION ALL SELECT

ID,USERNAME,EMAIL FROM SNAPSHOT ) tmp

GROUP BY ID, USERNAME,EMAIL

HAVING
COUNT (*) = 1

ORDER
BY ID

Apparantly the HAVING statement ensures selecting all records where at
least 1 field differs

Will this work in Version 3 and/or version 4 of DBISAM (or something
similar) or failing that what is the best way to go about it (Assume
Version 3 please)

Many thanks

Mike









--
Tue, Feb 12 2008 2:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mike,

Use this script (DBISAM 3):

SELECT ID, USERNAME,EMAIL
INTO MEMORY Temp
FROM KEYS
UNION ALL
SELECT
ID,USERNAME,EMAIL
FROM SNAPSHOT;

SELECT *
FROM MEMORY Temp
GROUP BY ID, USERNAME,EMAIL
HAVING COUNT (*) = 1
ORDER BY ID;

Just be sure to delete the in-memory Temp table when you're done working
with it.

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Feb 12 2008 3:27 PMPermanent Link

"Nowhere"
Many thanks for the quick reply

Mike
Image