Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Combining of two tables
Message
 
 
À
26/11/2001 15:04:45
Michael Harris
Harris and Harris Consultants
Temple Hills, Maryland, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00585785
Message ID:
00585957
Vues:
27
This message has been marked as the solution to the initial question of the thread.
>Sergey,
>
>The fields that I listed are the key fields. If they match, I want to combine the records from both tables into a record in the result table. If they don't match, I want to include each record that doesn't match in the new table with the corresponding fields updated in the result table.
>

For matching records all fields will be filled. For unmatching records there will be nulls in the fields from unmathed record.
SELECT ;
	NVL(TableA.Year, TableB.Year) AS Year, ;
	NVL(TableA.Borrower, TableB.Borrower) AS Borrower, ;
	NVL(TableA.Period, TableB.Period) AS Period, ;
	NVL(TableA.Rownum, TableB.Rownum) AS Rownum, ;
	NVL(TableA.e, TableB.en) AS exchange, ;
	TableA.FiledA1, TableA.FiledA2, ..., ;
	TableB.FiledB1, TableB.FiledB2, ... ;
  FROM TableA FULL OUTER JOIN TableB ;
    ON TableA.Year = TabelB.Year ;
   AND TableA.Borrower = TableB.Borrower ;
   AND TableA.Period = TableB.Period ;
   AND TableA.RowNum = TableB.RowNum ;
   AND TableA.e = TableB.En ;
INTO CURSOR crsResult
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform