You also have the option.. of @@IDENTITY.. if you are SQL Server... and it autmatically incremented...can remember what it is on Oracle.
<Cfquery...> insert into... whatever select @@IDENTITY as MAXID from tableName Joe > -----Original Message----- > From: Bryan Love [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 18, 2002 6:49 PM > To: CF-Talk > Subject: RE: Las record > > > Different DB's provide different ways of doing this, but the only > universal > way I know of is this: > > Assuming the key is numeric and increments ascending: > <cftransaction> > <cfquery...> > do the insert > </cfquery> > <cfquery...> > SELECT MAX(whateverID) as maxID > FROM tablename > </cfquery> > </cftransaction> > The transaction tags prevent another thread from doing an insert > between the > two queries and screwing up the SELECT MAX... statement. > > If the key is random then you likely are generating it in the code and > already know it before the query is even run. > > +-----------------------------------------------+ > Bryan Love > Macromedia Certified Professional > Internet Application Developer > Database Analyst > TeleCommunication Systems > [EMAIL PROTECTED] > +-----------------------------------------------+ > > "...'If there must be trouble, let it be in my day, that my child may have > peace'..." > - Thomas Paine, The American Crisis > > "Let's Roll" > - Todd Beamer, Flight 93 > > > > -----Original Message----- > From: Webmaster [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 18, 2002 2:49 PM > To: CF-Talk > Subject: Las record > > > How do I get the Unique ID from the last field I inserted? > > ______________________________________________________________________ This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting. FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

