views:

342

answers:

2

Hi I have multiple columns in a mySQL table. Three of the columns are named i100s, i60s and i25s and what I want to do is get the sum of all three entries . currently I have this code

   '$query= "SELECT SUM(i100s),SUM(i60s),SUM(i25s) AS tkit FROM event WHERE acc='100' " ; 
    $result = mysql_query($query) or die(mysql_error());
    $row = mysql_fetch_assoc($result) ;
    $total =  $row['tkit'];' 

But it is not returning the correct result , can anyone help me please ?

Thanks Mick

A: 
SELECT (SUM(i100s) + SUM(i60s) + SUM(i25s)) AS tkit ...

This would return the sum of the sum of the columns.

mdm
+2  A: 

Combined sum of all three columns?

If so, simply add them up:

'$query= "SELECT SUM(i100s) + SUM(i60s) + SUM(i25s) AS tkit FROM event WHERE acc='100' " ;

HaukurHaf