Is it possible to select * where then add all results?

时间:2016-10-20 19:18:49

标签: mysql sql

I have a sql table with a user_id and an integer

Is it possible to select integer from table where user_id = ? then add all integer results together and return just the one integer result?

2 个答案:

答案 0 :(得分:2)

yes - try something along of the lines of:

SELECT SUM(integer) FROM tbl WHERE user_id = 'xxx'

答案 1 :(得分:2)

You could do something like

SELECT sum(integer) As ReturnValue
FROM table
WHERE user_id = [value]