Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help on VFP Update-SQL
Message
De
20/08/1998 12:22:48
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00128498
Message ID:
00128527
Vues:
22
>I have a problem, and don't know if it is a known bug, or misinterpretation.
>
>Here's what I want... Update a field for all records in a first table with the value of a field in a matching table with the same id.
>
>Ex:
>
>Update table1;
>  set txtfield1 = table2.txtfield1;
>  where table1.keyid = table2.keyid
>
>
>Here's the scenario to test with
>Create two tables with a keyid and txtfield1
>add 5 records to each with ID in each table set from 1-5
>in table 1, set the values = a,b,c,d,e
>in table 2, set the values = z,y,x,w,u
>
>If table 2 is currently on record 3 (item = x), only record 3 in table 1 (item = c) will be changed to the new value (item = x).
>
>I want the results to become
>1 = z
>2 = y
>3 = x
>4 = w
>5 = u
>
>I know that you can use views, but the process of work is being held in interim work tables that may require a full system update at a later time. Therefore, updateable views won't work for us.
>
>Any help would be greatly appreciated...
That's exactly how update SQL would work and nothing wrong there. It doesn't move pointer in table2 only in table1. You should change it to :
select table2
scan
  Update table1;
    set txtfield1 = table2.txtfield1;
    where table1.keyid = table2.keyid
endscan
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform