You need GROUP BY and Aggregate Functions , specifically SUM
$sql = "SELECT SUM(v1) as Sv1, SUM(v2) as Sv2, SUM(v3) as Sv3, SUM(v4) as Sv4, SUM(v5) as Sv5 FROM table GROUP BY v1, v2, v3, v4, v5"
The 'GROUP BY v1, v2 ...' is not strictly required by MySQL because of it's sloppy SQL syntax. It is with most other SQL dialects used by other DB engines so it is a good habit to get into if you want portable code and transferable skills.