You can use the LAST_INSERT_ID() function to return the last id that was
generated by an autoincrement column on your connection.  If you're within a
CFTRANSACTION block, that's guarenteed to be what you want, but if you're
not using transactions, then I'm only about 99% sure that it'll behave
correctly.

The reason is that without CFTRANSACTION in place, there's no assurance that
CF is using the given db connection for your request exclusively (meaning
two requests could use the same connection).  I can't imagine CF shares
connections across simultaneous requests, but I've yet to see an official
statement from MM that confirms this.

That being said, I used it without CFTRANSACTION for quite some time (all
through the 3.23.x series) without ever having issues.

Cheers,
barneyb

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, March 04, 2004 1:27 PM
> To: CF-Talk
> Subject: mysql id ?
>
> whats the "proper" way to get the last inserted id out, u
> cant use max(id)
> i dont believe. however say the last number was 56, there
> could be 20 or
> so 56's i just need to have the next one insert as 57.
> i know i can so some things with the query but it behaves odd
> sometimes
>
> ty
>
>
>
>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to