Reply
ORDER BY numberofaffectedrows DESC - Please help!
Old 04-06-2007, 11:32 PM ORDER BY numberofaffectedrows DESC - Please help!
Skilled Talker

Posts: 52
Basically what I'm trying to create is a scoreboard type thing, with people's usernames (withwho in the table) and have it ordered by the number of rows in the database where withwho is their name.
Here's my non-working query

SELECT DISTINCT withwho FROM game_listing ORDER BY COUNT(withwho) DESC

Please help, or if you need more info I'll provide a prompt response - thankyou.
Petsmacker is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-06-2007, 11:50 PM Re: ORDER BY numberofaffectedrows DESC - Please help!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
Try something like:

SELECT DISTINCT withwho, COUNT(*) AS count FROM game_listing ORDER BY count DESC
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 04-07-2007, 12:05 AM Re: ORDER BY numberofaffectedrows DESC - Please help!
Skilled Talker

Posts: 52
I tried, no luck, mysql_error says:
Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/sites/tbhg.co.uk/public_html/leagues.php on line 222
Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause


So I turned the ORDER BY into a GROUP BY but:
Can't group on 'count'

Anymore suggestions?
Petsmacker is offline
Reply With Quote
View Public Profile
 
Old 04-07-2007, 12:47 AM Re: ORDER BY numberofaffectedrows DESC - Please help!
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Wireless Audio
Posts: 2,320
Name: Keith Marshall
Location: West Hartford, CT
SELECT withwho, COUNT(*) AS count FROM game_listing GROUP BY withwho ORDER BY count DESC
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 04-07-2007, 01:19 AM Re: ORDER BY numberofaffectedrows DESC - Please help!
Skilled Talker

Posts: 52
Fantastic work sir, it works perfectly and has taught me something I can use in future - cheers mate!
Petsmacker is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to ORDER BY numberofaffectedrows DESC - Please help!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.13327 seconds with 12 queries