Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Brain Cramp
Message
 
 
To
14/04/2003 17:57:26
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00777479
Message ID:
00777484
Views:
8
>Hi All,
>
>It's Monday... what can I say? I cannot recall the SQL syntax for updating the values in one table with values from another. I have a customer table. I want to populate the average payment age with values computed from other transaction tables. The common field is customer ID.
>
>It should start like this...
>
>UPDATE customer ;
> set customer.avgage with temptable.avgage ;
> Where customer.id == temptable.id
>
>and there is a clause that needs to be at the end to have each customer.ID validated and updated by the temptable.
>
>Right now I can get one record to update... I guess I must have learned something new and this is the information that got replaced in my pea brain... wee haw!
>
>Thanks!
Hi Paul,

You may do something like that in SQL Server but not in VFP because VFP UPDATE command doesn't support table join. In VFP you have a couple of choices.
* SCAN + UPDATE
SELECT temptable
SCAN
  UPDATE customer ;
    set customer.avgage with temptable.avgage ;
    Where customer.id == temptable.id
ENDSCAN
* SET RELATION + REPLACE
SELECT temptable
INDEX ON id TAG id
SET ORDER TO id
SELECT customer 
SET RELATION TO id INTO temptable
REPLACE customer.avgage with temptable.avgage ;
  FOR FOUND("temptable")
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform