Hi,

Yes it is possible to use sum with Update, subject to the constraint -table to be updated must not present in the FROM clause of the select stmt. But in your query, the table to be updated is present in the FROM clause. Hence update doesn't support that and have to go for some procedures..

Thanks
ViSolve DB Team

----- Original Message ----- From: "Ahmad Al-Twaijiry" <[EMAIL PROTECTED]>
To: "MySQL List" <mysql@lists.mysql.com>
Sent: Saturday, February 17, 2007 11:00 PM
Subject: sum with update


Hi Everyone

I have a question regarding SUM and Update.

is it possible to use SUM with Update ?

for example I have 3 tables

table_1:
idT1               Price
1                    20
2                    30
3                    50
4                    20

table_2:
idCust               Total                  idT1
2                       3011                 2
2                       221                   1
4                       2                       2
3                       31                     1
2                       302                   4
2                       30                     1

table_3:
idCust              Account
2                           200
3                           19
3                            99


I want to update table_3.Account        **IF**     (table_3.Account +
SUM(table_2.Total* table_1.Price) ) small than 1000 for each customer
(idCust)

is this possible using only SQL or I have to do it in programming ?


Thanks
--
echo "Hello World :)"



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to