Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select last 5 records (NEWBIE) 1

Status
Not open for further replies.

dnml

Technical User
Mar 4, 2003
7
AU
Hi,

I want to run a query that will return the last five records from a table. I am a newbie to SQL and MySQL so what I have been trying so far has not worked:

SELECT table.col1, table.col2, table.col3
FROM table
WHERE rownum >= count(*)-5

Can anyone put me on the right track to get this working?

Thanks in advance,

Dan
 
[tt]SELECT table.col1, table.col2, table.col3
FROM table
ORDER BY column DESC
LIMIT 5[/tt]
should do it. //Daniel
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top