All pastes #796797 Raw Edit

Untitled

public text v1 · immutable
#796797 ·published 2007-11-25 12:45 UTC
rendered paste body
CREATE TEMPORARY TABLE TempTable SELECT DISTINCT snatched.userid
FROM snatched
INNER JOIN torrents ON snatched.torrentid = torrents.id
AND torrents.id= ". sqlesc($_GET['id']) ." LIMIT 250;

SELECT torrents.name, torrents.id, categories.name, torrents.filename, COUNT( snatched.userid ) 
FROM torrents
INNER JOIN snatched ON snatched.torrentid = torrents.id
INNER JOIN TempTable ON snatched.userid = TempTable.userid
INNER JOIN categories ON categories.id = torrents.category
GROUP BY 1 
ORDER BY 5 DESC
LIMIT 0, 11;

DROP TABLE TempTable;