Although technically correct, this approach (using Max ID) is not
recommended for large sites.  

A more appropriate approach would be to use the CreateUUID() function to
calculate an ID value (to be stored in a variable), which result id an
ID value which would be known "by the page" and eliminate the need for
the SELECT MAX( ID) FROM... statement entirely.

While the UUID value would consume a lot more disk space then the
auto-increment integer, as the saying goes... disk space is cheap.  This
would significant improve the performance of the server, and therefore
the site.


Sean
 -----Original Message-----
From:   Duane Boudreau [mailto:[EMAIL PROTECTED]] 
Sent:   Friday, May 12, 2000 3:41 PM
To:     [EMAIL PROTECTED]
Cc:     [EMAIL PROTECTED]
Subject:        RE: SQL Max record ID ?

Try this Nelson:

<cftransaction>
<cfquery ....>
        insert into myTable1 ( ..... )
        values ( ..... )
</cfquery>
<cfquery ....>
        SELECT MAX(SomeID) AS NewSomeID
        FROM myTable2
</cfquery>
</cftransaction>

Using cftransaction insures that you get the newest SomeID inserted.

Duane Boudreau,
Project/Beta Manager, eMPower
Director, Web Technologies
Ektron, Inc.
http://www.ektron.com
5 Northern Blvd, Suite 6
Amherst, NH 03031
Tel: 603-594-0249
Fax: 603-594-0258



>From: Nelson Sauve <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: cf-talk <[EMAIL PROTECTED]>
>Subject: SQL Max record ID ?
>Date: Mon, 08 May 2000 11:28:50 -0700
>
>Hello,
>
>I have two tables Table #1 has an automatic increment field (someID).
>
>When I add a new record to Table #1 I want to take that someID field
>just created and use it in Table2 (separate templates) when I create a
>record for Table #2. That is I want the maximum value for someID in the
>table.
>
>Can anyone help ?
>
>Thanks,
>Nelson
>
>
>-----------------------------------------------------------------------
----
---
>Archives: http://www.eGroups.com/list/cf-talk
>To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
or
>send a message to [EMAIL PROTECTED] with 'unsubscribe'
in
>the body.

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

------------------------------------------------------------------------
----
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
or
send a message to [EMAIL PROTECTED] with 'unsubscribe'
in
the body.

------------------------------------------------------------------------
------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to