Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Merge 2 tables into 1
Message
 
 
À
15/05/2007 10:45:13
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01225554
Message ID:
01225575
Vues:
20
This message has been marked as a message which has helped to the initial question of the thread.
>>>Hi all,
>>>Is there any quick way to merge 2 table into 1?
>>>Thanks,
>>>Tamas
>>
>>Depending on what do you mean by that - vertical or horisontal merge?
>>
>>If both tables have the same structure and you want to append records from one to another, then look into INSERT SQL or APPEND FROM commands.
>>
>>If you want to add extra fields, when how do you want to combine records - based on some key field?
>
>I'd like to merge them vertically.
>for example:
>
>*********
>table1
>
>field1  | field2
>a1	| b1
>a2	| b2
>
>*********
>table2
>
>field3  | field4
>c1	| d1
>c2	| d2
>
>*********
>mergedtable
>
>field1  | field2 | field3 | field4
>a1	| b1	 | c1	  | d1
>a2	| b2	 | c2	  | d2
>
That's actually a horisontal merge.

Ok, here is the idea:
select recno() as RecNum, * from Table1 into cursor curFirst
select recno() as RecNum, * from Table2 into cursor curSecond

select field1, field2, field3, field4 from curFirst outer join curSecond on ;
curFirst.RecNum = curSecond.RecNum into table myMergedTable
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform