View Single Post
Old 01-02-2008, 02:23 AM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

Hmmm. I don't see any immediate issues standing out. Could you possibly attach your MySQL dump with dummy data so we can emulate and ponder?

I reformatted the SQL if anybody else wishes to have a stab at it.

sql Code:
SELECT
    votes.poll_id AS votes_pollid,
    COUNT(item_id) AS count,
    item_id,
    items.*
FROM       
    votes
LEFT JOIN
    items
ON  
    votes.id = items.poll_id
WHERE  
    votes.poll_id = 1
GROUP BY
    item_id
ORDER BY
    count DESC
LIMIT  
    3;

Personal preference really on the formatting!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote