cs.punk Posted September 3, 2009 Share Posted September 3, 2009 How do i select the last row? i have a database, every time someone logs in, a entry is added into the database.. but i cant find how to select the last row from the result set. i Can only loop the result with PHP... but thats uses too much resources. Link to comment https://forums.phpfreaks.com/topic/173016-select-bla-bla-and-from-there-select-the-last-row/ Share on other sites More sharing options...
rhodesa Posted September 3, 2009 Share Posted September 3, 2009 you need a column you can sort on...this can be an auto_increment field or a datetime field...assuming you have an auto_increment field called login_id, it would look like: SELECT * FROM loginTable ORDER BY login_id DESC LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/173016-select-bla-bla-and-from-there-select-the-last-row/#findComment-911869 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.