On Thu, 31 Jan 2002, DL Neil wrote:
> Date: Thu, 31 Jan 2002 21:28:04 -
> From: DL Neil <[EMAIL PROTECTED]>
> To: "William R. Mussatto" <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED]
> Subject: Re: next insert id (slightly OT)
>
> William,
>
&
William,
> > What should be understood is that MySQL's implementation of AUTO_INCREMENT
>requires a particular/different
> > philosophical view: that first the 'primary row' is to be stored, then the
>AUTO_INCREMENT data captured, and
> > finally the dependent row is stored (in the second table
On Thu, 31 Jan 2002, DL Neil wrote:
...
>
> What should be understood is that MySQL's implementation of AUTO_INCREMENT requires
>a particular/different
> philosophical view: that first the 'primary row' is to be stored, then the
>AUTO_INCREMENT data captured, and
> finally the dependent row is
I'm not going to address these comments to anyone - in an attempt to avoid
inter-personal conflict...
Herewith some psychology and philosophy:
- some people can't be bothered to read the manual
- writing a (good/complete) manual is even harder than reading it
- fully appreciating each fine deta
At 17:38 -0800 1/29/02, James Montebello wrote:
>Other people do know how to read manuals, Paul.
>
>If the original poster made any assumptions about the NEXT value in the
>auto increment field based on the value of LAST_INSERT_ID, that assumed
>value will be invalid the second another row is writ
Other people do know how to read manuals, Paul.
If the original poster made any assumptions about the NEXT value in the
auto increment field based on the value of LAST_INSERT_ID, that assumed
value will be invalid the second another row is written to the table.
If I did this:
INSERT INTO foo S
The original question that started this thread was:
>>
>>I need to find out what the next value will be in an auto_increment field
>>will be. could someone help me out with the select statement?
To which I replied:
>
>You can't find out what it *will be* until you actually create the record.
>T
At 15:33 -0800 1/29/02, James Montebello wrote:
>This result will be invalid when the a new row is written to the table,
>whether it's part of a transaction or not, no matter what the table type.
>I said as much, but perhaps I was a bit too cryptic.
>
>Generally speaking, getting this value reliab
At 15:30 -0800 1/29/02, laszlo wrote:
>And then you hope that between 'insert' and 'select' nobody else inserted
>another record?
Only for the last method. The first two return client-specific values.
>
>laszlo
>
>Johnny Withers wrote:
>
>> INSERT into the table
>> then SELECT last_insert_id(
At 15:35 -0800 1/29/02, James Montebello wrote:
>Of course, if you do LAST_INSERT_ID, then try to use the value while someone
>else is doing an insert, you're in the same boat. Neither method is reliable
>without a lock.
That's incorrect. LAST_INSERT_ID() is client-specific,
other clients can't
* James Montebello
> Of course, if you do LAST_INSERT_ID, then try to use the value
> while someone else is doing an insert, you're in the same boat.
> Neither method is reliable without a lock.
This is not correct. The LAST_INSERT_ID() function return the last inserted
auto increment key for _th
Montebello" <[EMAIL PROTECTED]>
>To: "Joel Wickard" <[EMAIL PROTECTED]>
>Cc: <[EMAIL PROTECTED]>
>Sent: Tuesday, January 29, 2002 4:16 PM
>Subject: Re: next insert id
>
>
>
>SELECT MAX(id) FROM table;
>
>will get you the highest va
Of course, if you do LAST_INSERT_ID, then try to use the value while someone
else is doing an insert, you're in the same boat. Neither method is reliable
without a lock.
james montebello
On Tue, 29 Jan 2002, Paul DuBois wrote:
> At 15:16 -0800 1/29/02, James Montebello wrote:
> >SELECT MAX(i
This result will be invalid when the a new row is written to the table,
whether it's part of a transaction or not, no matter what the table type.
I said as much, but perhaps I was a bit too cryptic.
Generally speaking, getting this value reliably while other work is
going on is only possible if
And then you hope that between 'insert' and 'select' nobody else inserted
another record?
laszlo
Johnny Withers wrote:
> INSERT into the table
> then SELECT last_insert_id()
>
> or when using php
>
> query(INSERT QUERY)
> $last_id=mysql_insert_id()
>
> OR
>
> INSERT
> SELECT MAX(id) FROM tablen
At 15:16 -0800 1/29/02, James Montebello wrote:
>SELECT MAX(id) FROM table;
>
>will get you the highest value for 'id', that +1 will be the 'next' value,
>until someone inserts a new row into that table.
Which may already have happened between the time you created your record
and the time you iss
Not _necessarily_ true, surely, if there's another transaction active at
the moment (assuming you are using a table that supports transactions)...?
At 03:16 PM 1/29/2002 -0800, James Montebello wrote:
>SELECT MAX(id) FROM table;
>
>will get you the highest value for 'id', that +1 will be the 'n
- Original Message -
From: "James Montebello" <[EMAIL PROTECTED]>
To: "Joel Wickard" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Tuesday, January 29, 2002 4:16 PM
Subject: Re: next insert id
SELECT MAX(id) FROM table;
will get you the highe
At 17:03 -0800 1/29/02, Joel Wickard wrote:
>database,sql,query,table
>
>
>I need to find out what the next value will be in an auto_increment field
>will be. could someone help me out with the select statement?
You can't find out what it *will be* until you actually create the record.
Then you g
INSERT into the table
then SELECT last_insert_id()
or when using php
query(INSERT QUERY)
$last_id=mysql_insert_id()
OR
INSERT
SELECT MAX(id) FROM tablename
assuming id is the auto incremnt field.
-
Johnny Withers
[EMAIL PROTECTED]
p. 601.853.0211
c. 601.209.4985
-O
SELECT MAX(id) FROM table;
will get you the highest value for 'id', that +1 will be the 'next' value,
until someone inserts a new row into that table.
james montebello
On Tue, 29 Jan 2002, Joel Wickard wrote:
> database,sql,query,table
>
>
> I need to find out what the next value will be in
21 matches
Mail list logo