How to construct this query? (Ordering by COUNT() and joining with users table)

Posted by Andrew on Stack Overflow See other posts from Stack Overflow or by Andrew
Published on 2010-04-22T01:42:11Z Indexed on 2010/04/22 1:43 UTC
Read the original article Hit count: 229

Filed under:
|

users table:

id-user-other columns

scores table:

id-user_id-score-other columns

They're are more than one rows for each user, but there's only two scores you can have. (0 or 1, == win or loss). So I want to output all the users ordered by the number of wins, and all the users ordered by the numbers of losses.

I know how to do this by looping through each user, but I was wondering how to do it with one query. Any help is appreciated!

© Stack Overflow or respective owner

Related posts about mysql

Related posts about query