Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Merge 2 tables into 1
Message
De
15/05/2007 11:12:32
 
 
À
15/05/2007 11:00:47
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:
01225588
Vues:
24
>>>>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
>>
>
>Assuming that reccount() is the same in both tables.
>
>Select recno() as recnum,field1,field2 from table1 into cursot tmp1 nofilter
>Select recno() as recnum,field3,field4 from table2 into cursot tmp2 nofilter
>Select field1,field2,field3,field4 from tmp1 inner join tmp2 on tmp1.recnum=tmp2.recnum
>
>Use Outer Join in case of different record counts.

Thanks a lot, it works.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform