Subject Re: [firebird-support] Small Update SQL trick (problem)
Author ibrahim bulut
update customers c
set
totalorders = (select sum(Orders.TotalOrders) from orders orders
where orders.CustomerID = c.id)
where c.id = :id


----- Original Message -----
From: "majstoru" <majstoru@...>
To: <firebird-support@yahoogroups.com>
Sent: Tuesday, December 27, 2005 12:48 AM
Subject: [firebird-support] Small Update SQL trick (problem)


> Hi,
>
> I have a small problem, maybe is not a problem, but an expret trick.
> I'm using Firebird 2 and I have two tables fex: Customers, Orders! I
> would like to write a SQL statment to update Customers (field
> TotalOrders) from table Orders.
> Something like:
> UPDATE Customers
> SET TotalOrders = SUM(Orders.TotalOrders)
> // begin of the problem
> The continue of this SQL must update all customers form table orders,
> something like FOR DO (in delphi).
> Important: I need this solution like SQL statment no StoredProcedure!
>
> Thanks for ALL...
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
> __________ NOD32 1.1340 (20051226) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
>
>