List:General Discussion« Previous MessageNext Message »
From:Max Anderson Date:May 8 2002 3:57pm
Subject:RE: inserting record
View as plain text  
One solution is to maintain your own table of team_ids, like an Oracle
sequence table.

For example:

TeamIDGenerator
---------------
TeamId
DateIssued

When you want a new TeamId,

SELECT TeamID + 1 FROM TeamIDGenerator;
(Do some stuff)
UPDATE TeamIDGenerator SET TeamID = TeamID + 1, DateIssued=CURDATE();

There are issues with thread safety here but if you are writing the
application you will know how the tables are accessed.  Are there multiple,
concurrent requests for TeamIDs?

I believe there may be something like MS SQL Servers SELECT @@IDENTITY which
returns the last insert ID but  am not too sure.

- Max

Martin Anderson
QA Engineer
ProfitLogic
Eleven Cambridge Center
Cambridge, MA 02142
t: 617.218.1946


-----Original Message-----
From: Steve Buehler [mailto:steve@stripped]
Sent: Wednesday, May 08, 2002 11:02 AM
To: mysql
Subject: inserting record


	I am running mysql with a php frontend.  I am trying to add teams to
a 
table and when I do, it gives them a team_id number that is in an 
auto_increment column.  This is no problem.  The problem is that I need to 
know that team_id so that I can also enter the team_id into another 
table.  Any help would be appreciated.

Thank You in advance
Steve


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <mysql-thread108367@stripped>
To unsubscribe, e-mail
<mysql-unsubscribe-Martin.Anderson=bodoin.com@stripped>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
Thread
inserting recordSteve Buehler8 May
  • RE: inserting recordJay Blanchard8 May
  • Re: inserting recordGeorg Richter8 May
  • Re: inserting recordRichard Emery8 May
  • Re: inserting recordJim Philips8 May
RE: inserting recordMax Anderson8 May
Re: inserting recordSteve Buehler8 May
Re[2]: inserting recordSteve Buehler8 May