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 Quote 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. Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.