return a newly created SID

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
tkstock
Forum Newbie
Posts: 6
Joined: Wed Aug 22, 2007 10:29 pm
Location: Richmond, VA

return a newly created SID

Post 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!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
tkstock
Forum Newbie
Posts: 6
Joined: Wed Aug 22, 2007 10:29 pm
Location: Richmond, VA

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It is connection specific.
User avatar
tkstock
Forum Newbie
Posts: 6
Joined: Wed Aug 22, 2007 10:29 pm
Location: Richmond, VA

Post by tkstock »

feyd wrote:It is connection specific.
Fantastic! Thanks!!
Post Reply