List:MySQL on Win32« Previous MessageNext Message »
From:Steve Ruby Date:January 8 2001 8:47pm
Subject:Re: 5 last records ?
View as plain text  
FL wrote:
> 
> Hi,
> 
> How to build an efficient query to display the 5 last records (order by
> date) ?


You can only display the "last" 5 ordered by date ASCENDING if you know
the total number of rows, otherwise you can cheat by sorting DESCENDING
and viewing the first 5..

select * from <tablename> order by <datecolumn> desc limit 5;
Thread
mysql_affected_rows() reportedly returns 0 for queries on BDBtablesCynic8 Jan
  • 5 last records ?FL8 Jan
  • Re: 5 last records ?Stephen Woodbridge8 Jan
  • Re: 5 last records ?Steve Ruby8 Jan
  • Re: 5 last records ?Jorge del Conde9 Jan
  • Re: mysql_affected_rows() reportedly returns 0 for queries onBDB tablesCynic9 Jan