acidglitter Posted December 8, 2007 Share Posted December 8, 2007 There was this really simple code and I can't remember what it was and I can't find it.. But right after you inserted something into a table you would do something like mysql_newest_id() and it would get the id of the row just barely entered without having to start a new query and fetch it.. Does anyone know what that code is? Link to comment https://forums.phpfreaks.com/topic/80794-solved-get-the-newest-id-from-a-mysql-table/ Share on other sites More sharing options...
dbo Posted December 8, 2007 Share Posted December 8, 2007 mysql_last_insert_id() or something like that maybe just mysql_insert_id() Link to comment https://forums.phpfreaks.com/topic/80794-solved-get-the-newest-id-from-a-mysql-table/#findComment-409823 Share on other sites More sharing options...
emehrkay Posted December 8, 2007 Share Posted December 8, 2007 I recently asked this question. Run this query SELECT LAST_INSERT_ID() AS last_id Link to comment https://forums.phpfreaks.com/topic/80794-solved-get-the-newest-id-from-a-mysql-table/#findComment-409825 Share on other sites More sharing options...
acidglitter Posted December 8, 2007 Author Share Posted December 8, 2007 mysql_insert_id(); works. Thanks! Link to comment https://forums.phpfreaks.com/topic/80794-solved-get-the-newest-id-from-a-mysql-table/#findComment-409826 Share on other sites More sharing options...
acidglitter Posted December 8, 2007 Author Share Posted December 8, 2007 I recently asked this question. Run this query SELECT LAST_INSERT_ID() AS last_id I think the other way is faster though.. It doesn't even need any queries. Link to comment https://forums.phpfreaks.com/topic/80794-solved-get-the-newest-id-from-a-mysql-table/#findComment-409828 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.