>>>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