Re: sum with update

2007-02-19 Thread ViSolve DB Team

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" 
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
120
230
350
420

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
399


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]



sum with update

2007-02-17 Thread Ahmad Al-Twaijiry

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
120
230
350
420

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
399


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 :)"