sql >> Base de Datos >  >> RDS >> Mysql

php/mysql agrega filas para obtener el total

Para agregar campos (columnas):

SELECT col1, col2, col3, (col1+col2+col3) AS Total FROM table;

Para sumar filas, use SUM() agregado:

SELECT
  userid,
  SUM(col1) AS col1_total,
  SUM(col2) AS col2_total
FROM table
GROUP BY userid