Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update from Sub-query
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01519023
Message ID:
01519027
Views:
33
>>Hi,
>>
>>I would like to create a SQL UPDATE that will update from a subquery. I have seen it here (on UT) but can't seem to find a message with an example. What I am trying to do is to have UPDATE that sets a value in a field based on the calculations done in another table in a sub-query. That is, I would have something like this:
>>
>>
>>UPDATE TableA Set Field1 = SUM_TOT  (select SUM( FLDA + FLDB) AS SUM_TOT FROM TableB group by 
>> TableB.FLDC)
>>
>>
>>I am sure that above is not correct. But what is the correct syntax?
>>
>>TIA.
>
>
>Update TableA Set Field1 = ST.Sum_TOT
>FROM TableA INNER JOIN (select sum(FldA+FldB) as Sum_Tot from TableB group b y FldC) ST
>ON TableA.FieldC = ST.FieldC
Thank you very much.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform