NLCJ Posted May 6, 2010 Share Posted May 6, 2010 Hello, I want to count one column where the userid is the same. Let's say I got this: $get = mysql_query("SELECT column FROM table WHERE userid='1'); [code=php:0] For example, this gives: [code] UserID - Column 1 - 24 1 - 58 1 - 89 I want that this goes like: 24 + 58 + 89, how can I do this? Or is this a PHP specific question? Sorry that I didn't use a table, but it just doesn't insert one when I say it should. Regards, NLCJ Quote Link to comment https://forums.phpfreaks.com/topic/200929-counting-a-specific-column-of-multiple-rows/ Share on other sites More sharing options...
Mchl Posted May 6, 2010 Share Posted May 6, 2010 SELECT SUM(column) FROM table WHERE userid = 1 To get sums for all users: SELECT userid, SUM(column) FROM table GROUP BY userid Quote Link to comment https://forums.phpfreaks.com/topic/200929-counting-a-specific-column-of-multiple-rows/#findComment-1054343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.