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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

newest record

Status
Not open for further replies.
Joined
Apr 27, 1999
Messages
705
Location
US


Hello,

I have a table with timestamps. I am trying to find or return the newest/latest record from MySQL. Any ideas? Is there a function that will return the latest record?

Thanks in advance.
fengshui_1998
 
SELECT * FROM daTable
WHERE daTimestamp = ( SELECT MAX(daTimestamp) FROM daTable )


r937.com | rudy.ca
 
Or:
Code:
SELECT * FROM daTable ORDER BY daTimestamp DESC LIMIT 1;

In any case, make sure you set an index on the timestamp field.

+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top