Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
UPDATE SQL, How to use with correlated query.
Message
From
10/05/2005 15:57:11
 
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01011797
Message ID:
01012579
Views:
18
>That's a great recomendation, this thread comes as a way to know how to improve the >FROM clause and correlated sentences with the new VFP9 UPDATE-SQL feature.

Well, with VFP9 you can also do subqueries and therefore it can also be done this way in one SQL-Update:

Update cAgent ;
SET yMonth = t2.YTot ;
FROM (Select iAgentID, Sum(yAmount) As YTot ;
FROM cMovs GROUP BY 1 ;
WHERE Year(dDate) = 2005 And Month(dDate) = 1) as t2;
WHERE t2.iAgentID = cAgent.iAgentID ;
AND cAgent.nYear = 2005 AND cAgent.nMonth = 1

But that doesn't make it faster than the two selects done one after another.

I'd say the speed would be improved if records in cMovs were physically ordered by time, because although a index speeds things up, if the hard disk drive head doesn#t have to move much, it may even get faster. And normally the records would be in time order, wouldn't they?

Bye, Olaf.
Previous
Reply
Map
View

Click here to load this message in the networking platform