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:
01519025
Views:
74
This message has been marked as the solution to the initial question of the thread.
>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
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform