Vivid Lust Posted December 22, 2007 Share Posted December 22, 2007 Hi, im not very good with SQL (yet). And i was wondering what the query would be to do this: Gettting the highest ID number. Say there was: 1 stuff 2 stuff 3 stuff 4 stuff 5 stuff How would the query get the 5? and then if i added more it would get the last one. Or the highest ID. Sounds simple but i have no idea. Thanks in advanced!!! Vivid Link to comment https://forums.phpfreaks.com/topic/82811-solved-what-would-the-sql-query-be-for-this/ Share on other sites More sharing options...
Barand Posted December 22, 2007 Share Posted December 22, 2007 SELECT MAX(id) FROM tablename But use with caution. On a busy site it may not be the id of the last record you added and could be out-of-date by the time you use it. Link to comment https://forums.phpfreaks.com/topic/82811-solved-what-would-the-sql-query-be-for-this/#findComment-421214 Share on other sites More sharing options...
fenway Posted December 23, 2007 Share Posted December 23, 2007 Agreed... having a timestamp would be more appropriate. Link to comment https://forums.phpfreaks.com/topic/82811-solved-what-would-the-sql-query-be-for-this/#findComment-421990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.