Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Brain Cramp
Message
 
 
À
14/04/2003 17:57:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Divers
Thread ID:
00777479
Message ID:
00777484
Vues:
9
>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--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform