Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to combine 3 tables into 1?
Message
De
13/07/1999 13:52:01
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00240803
Message ID:
00240864
Vues:
17
I've never needed to do this, but it looks like the set relation command will assist you.

If you want to combine record 1 in table 1 with record 1 in table 2 with record 1 in table 3 and record 2 in table 1 with record 2 in table 2 with record 2 in table 3 and so on, you should be able to do this:

Select table1
set relation to recno() into table2
set relation to recno() into table3 additive
list all table1.field1, table1.field2, table2.field1, table2.field2, table3.field1, table3.field2

Is that kinda what you are looking for?

>No, there are no links. The purpose of the main cursor is as a data source for a report. The three small cursors each represent a pair of columns in the final report. The resulting report format should have 6 columns side-by-side on the page. I'm attempting to use the detail portion of the report format to keep that part as simple as possible.
>
>This approach was necessary because the three column pairs can be from any three of about 15 tables of dissimilar data. I had to 'genericize' lots of things to get it down to 3 tables of free-form content.
>
>I'm working on an approach which copies the small table data to an array and then inserts it into the appropriate fields of the large table on a record-by-record basis.
>
>Any other thoughts will be appreciated.
>
>Thanks,
>Neil
>
>
>
>>>I need to consolidate info from 3 small tables (actually, cursors) into one, column by column. I would appreciate any suggestions as to a method, particularly as to keeping track of the record pointers during the process.
>>>
>>>Each small cursor has two fields, but any number of records. I want to copy all the records from table 1 into fields 1 and 2 of the large table, then copy all records from table 2 into fields 3 and 4 of the large table, and finally copy all the records from table 3 into fields 5 and 6 of the large table.
>>>
>>>I am expecting to use SCATTER TO array and GATHER to fieldnames to move the data. The problem I have is figuring out how to ensure tracking between the record numbers of each small table and the large table.
>>>
>>>I would appreciate any suggestions.
>>>
>>>Thanks,
>>>Neil Preston
>>
>>Is there a link between these three tables. You can do this with a SELECT statement and JOINs but without knowing what the link is, I can't suggest a solution at present.
--Todd Sherman
-Wake Up! Smell the Coffee!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform