RE: [PHP] Count total
| From: | Don Read | Date: | Mon, 20 Aug 2001 03:23:12 +0000 |
| Subject: | RE: [PHP] Count total | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63447@lists.php.net to get a copy of this message | ||
On 19-Aug-2001 Martin Kampherbeek wrote:
> Hi,
>
> Who can help me with the following problem?
> I have the tables score and totalscore.
>
> Score:
> id
> userid
> name
> score
>
> Totalscore:
> userid
> name
> totalscore
>
> In the table score one user can have mutiple scores. But in totalscore the
> userid is unique. Now I want to count all the score's of a user en place
> this at the same user in totalscore.
>
> Example of score:
> 1 1 Martin 10
> 2 2 John 5
> 3 3 Richard 12
> 4 1 Martin 3
> 5 3 Richard 8
> 6 1 Martin 7
> 7 2 John 15
>
> So I would like to know the total score of each user.
> But I don't know how to do this. Who can help me out?
>
REPLACE INTO Totalscore
SELECT userid,name,sum(score) from Score GROUP BY userid;
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.