Vivid Lust Posted November 6, 2008 Share Posted November 6, 2008 Hey, say I had this table; id foo 1 a 2 a 3 a 4 a 5 a 6 a 7 a How can I get the last value of the id column??? (7) Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/131640-getting-last-value-from-a-column/ Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 SELECT * FROM tableName ORDER BY id DESC LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/131640-getting-last-value-from-a-column/#findComment-683718 Share on other sites More sharing options...
fenway Posted November 6, 2008 Share Posted November 6, 2008 Depends what you mean by "last"... MAX(id) works too... but I prefer to have a timestamp to sort by. Link to comment https://forums.phpfreaks.com/topic/131640-getting-last-value-from-a-column/#findComment-683724 Share on other sites More sharing options...
rhodesa Posted November 6, 2008 Share Posted November 6, 2008 i guess i was assuming ID was an auto_increment value... Link to comment https://forums.phpfreaks.com/topic/131640-getting-last-value-from-a-column/#findComment-683732 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.