Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combining of two tables
Message
 
 
To
26/11/2001 15:04:45
Michael Harris
Harris and Harris Consultants
Temple Hills, Maryland, United States
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00585785
Message ID:
00585957
Views:
26
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--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform