CODING ACADEMY

View Original

How to find the sum of values in a MySQL table field

Recently I needed to find the sum of all values in a particular field within a MySQL table. This is how I went about doing it.

The actual code is really straightforward.

See this content in the original post

Hopefully this code does not require much explanation at all.

We are finding the sum of theField from the myTable database table.

That's all there is to it. 

If you would like to learn more about PHP, MySQL and PDO then enrol in the new course today.