Page 1 of 1

return a newly created SID

Posted: Wed Aug 22, 2007 10:39 pm
by tkstock
Hi,

I was wondering if there is a good way to return a newly created SID (auto_increment) from a MySQL databse when you insert a record?

So, if I insert a record, I want to add the SID of that record to another join table... and I can expect that the SID is the only unique key in this table.

Any suggestions?

Is there a way to insert records into two tables and use that SID in the join table with one insert query?

Thanks for your assistance!

Posted: Wed Aug 22, 2007 11:43 pm
by feyd

Posted: Wed Aug 22, 2007 11:56 pm
by tkstock
That will do it!!! Thanks!

For arguments sake, would there potentially be any concurrency issues? I know we're talking extreme case, but what if two people perform an insert at the same time - is there a potential issue? In a highly concurrent database, the possibility is there.. maybe?

Thanks, though. That function will work fine, but I'm playing devil's advocate.

Posted: Thu Aug 23, 2007 9:07 am
by feyd
It is connection specific.

Posted: Thu Aug 23, 2007 9:30 am
by tkstock
feyd wrote:It is connection specific.
Fantastic! Thanks!!