If you're using MySQL:

mysql_insert_id

If you're using MSSQL, you need to execute SELECT @@IDENTITY right after
your insertion operation. The result will give you the ID of your last
insertion. This won't work well if you're doing a bulk insert, though.


On Mon, 2002-10-07 at 15:46, Jason Young wrote:
> Apologies for what's probably an extremely newbie question..
> 
> Is there any way to have a database return its auto_increment field 
> during insert?  I have two different tables, when one inserts, I'd like 
> to be able to assign the value of the new auto_increment field to 
> another field in another table.
> 
> I guess I COULD go and make the second table auto_increment along with 
> it, but that would require a complete rewrite, and I'd like to avoid that...
> 
> Anyone have ideas, suggestions, or preferably.. an answer to my question? :)
> 
> Thanks
> -Jason
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to