Comunidad de diseño web y desarrollo en internet online

Como sumar capos de columnas

Citar            
MensajeEscrito el 28 Oct 2007 01:50 am
Como se pueden sumar las columnas de una tabla osea

id I campo1 I campo2
1 I 200 I 100
2 I 300 I 100
3 I 100 I 100

6 I 600 I 300 este resaultado como se obtiene ?

gracias

Por drakon

17 de clabLevel



 

msie
Citar            
MensajeEscrito el 28 Oct 2007 03:20 am
SELECT SUM(id) as sumaid, SUM(campo1) as sumacampo1, SUM(campo2) as sumacampo2 FROM tabla;

enjoy :).

Por DriverOp

Claber

2510 de clabLevel



 

opera
Citar            
MensajeEscrito el 29 Oct 2007 10:05 pm
Y para leer las sumas desde PHP ?

Por drakon

17 de clabLevel



 

msie
Citar            
MensajeEscrito el 29 Oct 2007 10:53 pm

drakon escribió:

Y para leer las sumas desde PHP ?


Eso ya lo deberias saber.-

Código :

$query = SELECT SUM(id) as sumaid, SUM(campo1) as sumacampo1, SUM(campo2) as sumacampo2 FROM tabla;
     $result = mysql_query($query,$link);
        while($row = mysql_fetch_array($result)){
             echo $row["sumaid"] . " - " . $row["sumacampo1"] . " - " . $row["sumacampo2 "] . " <br />";
               }

Por york3rs

Claber

561 de clabLevel

1 tutorial

Genero:Masculino  

LA___Chile

msie

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.