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;