Information générale
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
>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
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement