Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compare contents of two dbfs
Message
From
23/04/2003 21:25:16
 
 
To
23/04/2003 13:04:14
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00780688
Message ID:
00780951
Views:
8
>Hi,
>
>I would like two compare the contents of two dbf tables. I would like to update table1 with the contents of certain fields in table2, if an new record exists within table2.
>
>I don't know how to begin, any suggestions are appreciated.
>
>Thank you,

This is one of the new capabilities introduced in VFP8. I don't know how fast this query will be for large tables.
*-- field: f1 being the common field between the two tables
use table1 in 0 && has fields: f1, f2, f3
use table2 in 0 && has fields: f1, f2, f3

*-- add all records in table2 that are not in table1 based
*-- on field: f1. This is important as this query will not
*-- add a duplicate record from table2 to table1 if F1 already
*-- exists in table1.
insert into table1 (f1,f2) ;
  select f1,f2 from table2 ;
  where f1 not in ;
    (select f1 from table1)
HTH.
ramil
~~ learning to stand still
Previous
Reply
Map
View

Click here to load this message in the networking platform