So I'm being particularly dense I'm sure - but I'm struggling with what should be a simple (mysql) SQL statement in PHP.
I have two tables:
entry
containing the name & details of a competition entry.votes
containing a timestamp, unique ID, and entry_id. Each row with the entry_id matching the id of an entry represents one vote for that person's competition entry.
The rough Db Structures are:
entry table:
|id|name|email|created|deleted| [last two cols being datetime stamps]
votes table:
|id|entry_id|created|deleted|
My attempts (various rewrites, probably too tired!) have resulted in just one row being returned.
My latest attempt:
$sql = 'SELECT
s_id,
count(sv.s_id) as count
FROM
'vote AS sv
LEFT JOIN
'entry AS se on sv.entry_id = se.id
WHERE
sv.deleted = "0000-00-00 00:00:00"
AND
se.deleted = "0000-00-00 00:00:00"
ORDER BY
count DESC
LIMIT
10';
Can someone give me a steer on how best to achieve this?
I'm aiming for the top ten entries returned (by vote count) with the count included in the return data.
Thanks!
Steve