Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Query for differences
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00421436
Message ID:
00421457
Views:
16
>Is there a quick SQL query that would show records that are different in two files?

This will not work if you have any memo fields.

SELECT "Table one" AS tablenum, keyfield, field2, field3, ... ,fieldlast
FROM table1
WHERE keyfield NOT IN
(SELECT keyfield FROM table1
INNER JOIN table2 ON table1.field2 = table2.field2
AND table1.field3 = table2.field3
AND ... AND table1.fieldlast = table2.fieldlast)
UNION SELECT "Table two", keyfield, field2, field3, ... ,fieldlast
FROM table2
WHERE keyfield NOT IN
(SELECT keyfield FROM table1
INNER JOIN table2 ON table1.field2 = table2.field2
AND table1.field3 = table2.field3
AND ... AND table1.fieldlast = table2.fieldlast)

However, if you have a problem like this, maybe you don't have a keyfield. You might have to replace keyfield with whatever expression makes a compound key.
Previous
Reply
Map
View

Click here to load this message in the networking platform