ViSolve DB Team wrote:
Hi,

Try this..

UPDATE table2 inner join table1 on table2.playedid=table1.playerid
SET table2.totalscore=sum(table1.score)

Just a guess...

Thanks,
ViSolve DB Team

----- Original Message ----- From: "Ravi Kumar." <[EMAIL PROTECTED]>
To: <mysql@lists.mysql.com>
Sent: Wednesday, December 06, 2006 4:11 PM
Subject: Update query help


Dear Friends,

I have two tables: T1, T2.

T1 has 3 columns: playerid, gameid, score
T2 has 2 columns: playerid, totalscore.

I wish to update table T2 such that sum of T1.score of each player, gets
updated in T2.totalscore. It may be something like this:

update T2, T1 set T2.totalscore = sum(T1.score) where T1.playerid =
T2.playerid

OR

update T2, T1 set T2.totalscore = sum(T1.score) where T1.playerid =
T2.playerid group by playerid

However none of the above is working.

Where am I wrong? Please help.

The version of MySQL I am using is 4.1.14-standard-log.

Thanks,

Ravi.




--------------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.9/573 - Release Date: 12/5/2006


ViSolve, I think yo've missed a GROUP BY needed for every Aggregated function (like SUM) ;-)

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

Reply via email to