On the statement below where can I add a limit to get the last 10 id numbers from the database and from those ORDER BY likes DESC //likes is also a number $newest = mysql_query("SELECT * FROM `like` INNER JOIN (SELECT * FROM `like` GROUP BY likes DESC) s ON s.id = like.id"); PHP: EDIT: in other words this is my statement: $newest = mysql_query("SELECT * FROM `like` GROUP BY id DESC LIMIT 10"); PHP: ..and I want to after getting the last 10 id's, ORDER them BY likes
Hi, try this SELECT * FROM (SELECT * FROM `like` ORDER BY id DESC LIMIT 10) A ORDER BY likes DESC; Code (markup):