For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > November 2006 > Re: [PHP-DB] Simple question on auto_increment









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Simple question on auto_increment
Brad Bonkoski

2006-11-13, 6:56 pm

mario wrote:
> Hello,
>
> really a mysql question. Pls. help anyway.
>
> Is there a simple, common way to implemt the following:
> Say I have a table with a id autoincrement field.
> I wish to insert a record but just ist id value, get back the id value,
> use it to update the record.
>
> Do I need three separate mysql queries? Is there some trick I may use?
> Thanks Regards mario
>
>

www.php.net/mysql_insert_id --or-- www.php.net/mysqli_insert_id

(of course for your example to work all the other fields would have to
be nullable)
Christian Flothmann

2006-11-14, 7:56 am

> www.php.net/mysql_insert_id --or-- www.php.net/mysqli_insert_id
>
> (of course for your example to work all the other fields would have to
> be nullable)
>


Or even the MySQL function LAST_INSERT_ID():
http://dev.mysql.com/doc/refman/5.0....html#id2725312
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com