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!
return a newly created SID
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
mysql_insert_id() probably.
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.
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.