Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Query for differences
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00421436
Message ID:
00421457
Vues:
15
>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform