0

My table has 4 columns. I want the last column to be a SUM of the previous 3 columns.

I can use a select command to get the result I want:

SELECT strength + agility + defense AS StatSum FROM userstats

How do I do this?

EDIT: I am looking how to place the SELECT command in the column so that column 4 will display the sum of each row.

adam7918
  • 21
  • 2
  • possible duplicate of [Column calculated from another column?](http://stackoverflow.com/questions/5222044/column-calculated-from-another-column) – Jimmy T. Apr 12 '15 at 13:13

2 Answers2

0

Try soemthing like:

 SELECT strength, agility, defense, (strength + agility + defense) AS StatSum 
 FROM userstats
SMA
  • 36,381
  • 8
  • 49
  • 73
0

MySQL does not support calculated values for a column.

The only thing you could do is to use a view

Jimmy T.
  • 4,033
  • 2
  • 22
  • 38