Returning an Auto-Increment Field
Hello All: If I am adding a row to a table that has an auto-increment field, is there a way to query MySQL for the value of that field, once the new row is added? TIA -- Tim Johnson [EMAIL PROTECTED] http://www.alaska-internet-solutions.com http://www.johnsons-web.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Returning an Auto-Increment Field
I think that the mysql function LAST_INSERT_ID() is what you need. Tim Johnson wrote: Hello All: If I am adding a row to a table that has an auto-increment field, is there a way to query MySQL for the value of that field, once the new row is added? TIA -- - - Nikolas Galanis - - Computer Engineering Informatics Department - - University of Patras - - http://www.ceid.upatras.gr- - 061 997707- - - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Returning an Auto-Increment Field
Hi, select last_insert_id(); Regards, Gelu _ G.NET SOFTWARE COMPANY Permanent e-mail address : [EMAIL PROTECTED] [EMAIL PROTECTED] - Original Message - From: Tim Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 08, 2002 7:04 PM Subject: Returning an Auto-Increment Field Hello All: If I am adding a row to a table that has an auto-increment field, is there a way to query MySQL for the value of that field, once the new row is added? TIA -- Tim Johnson [EMAIL PROTECTED] http://www.alaska-internet-solutions.com http://www.johnsons-web.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Re: Returning an Auto-Increment Field/Thanks
Thanks to all for the responses. Especially to those who pointed my to documentation. Regards -tim- * Cliff [EMAIL PROTECTED] [021108 08:32]: You can use the function : mysql_insert_id() to get the value you've just added. Please see http://www.mysql.com/doc/en/mysql_insert_id.html for more information. Notice that you should call mysql_insert_id() immediately after the query that generates the value. - Original Message - From: Tim Johnson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Saturday, November 09, 2002 1:04 AM Subject: Returning an Auto-Increment Field Hello All: If I am adding a row to a table that has an auto-increment field, is there a way to query MySQL for the value of that field, once the new row is added? TIA -- Tim Johnson [EMAIL PROTECTED] http://www.alaska-internet-solutions.com http://www.johnsons-web.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php -- Tim Johnson [EMAIL PROTECTED] http://www.alaska-internet-solutions.com http://www.johnsons-web.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail [EMAIL PROTECTED] To unsubscribe, e-mail [EMAIL PROTECTED] Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php