Try this immediately after you insert a row. $sqlQuery = "select MAX(YOUR_COLUMN_NAME) from YOUR_TABLE_NAME"; -----Original Message----- From: timbo@komrades.dyndns.org [mailto:timbo@komrades.dyndns.org] Sent: Friday, 11 April 2003 9:59 AM To: Subject: Getting the value of an auto-increment Hello, I'm using an auto-increment field in a table as the primary key. What I want to know is when I use an INSERT query to add a row to the table is there a way I can get the value of the auto-increment field of the row that was just inserted? What I'm currently doing is messy but works: I get the current time and session id and write them to one of the fields in the row and INSERT that. I then do a query and find the row (thus getting the value of the auto-increment field) and then write the real data. I'm just hoping there's an easier way. Thanks in advance, Tim Coombes Komrades Ink. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php