I am trying to select rows with the 20 highest ‘TimeStamp’ value, and from those 20 rows the 1 row with the lowest ID value:
$result_last = mysql_query("SELECT * FROM (SELECT * FROM Events ORDER BY TimeStamp DESC LIMIT 20) ORDER BY ID ASC LIMIT 1");
The above query doesn’t work, but it makes sense to me. Is there something wrong with this query?
The error is
#1248 - Every derived table must have its own aliasand this is indeed true. This should work: