user5443928
user5443928

Reputation:

How count sum of field value and sort them as per userid using PHP and MySQL

I need some help. I need to calculate the sum of numeric field value as per userid and place them into array using MySQL and PHP. I am explaining my table below.

db_like:

id     like    userid

  1       1        10

  2       2        11

  3       1        10

  4       2        11

Here I need to count the sum of like field value as per userid and place the result into array. Please help.

Upvotes: 0

Views: 44

Answers (1)

Remco K.
Remco K.

Reputation: 717

SELECT SUM(`like`) AS `likes` FROM [table] GROUP BY `userid`;

Upvotes: 1

Related Questions