faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 2 people (100%) answered Yes
Recently 2 of 2 people (100%) answered Yes

Entry

How can I output the latest 25 rows from a table ?

Aug 31st, 2004 00:40
Maurice, Philip Olson, Thomas Cherian,


It depends on what you mean by "Latest" but let's assume this table has
auto_increment ids for every record, we'll call this column id.  So now
create your SQL query and ORDER BY the id, in descending order, and add
a limit:
  SELECT id,name,email FROM sometable ORDER BY id DESC LIMIT 25
That will select the last 25 records from the table.