Re: next insert id

2002-01-30 Thread DL Neil
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

Re: next insert id (slightly OT)

2002-01-30 Thread William R. Mussatto
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

Re: next insert id (slightly OT)

2002-01-30 Thread DL Neil
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) - a

Re: next insert id (slightly OT)

2002-01-30 Thread William R. Mussatto
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, What should be understood is that MySQL's implementation

next insert id

2002-01-29 Thread Joel Wickard
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? - Before posting, please check:

Re: next insert id

2002-01-29 Thread James Montebello
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 an

RE: next insert id

2002-01-29 Thread Johnny Withers
-Original Message- From: Joel Wickard [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:04 PM To: [EMAIL PROTECTED] Subject: next insert id 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

Re: next insert id

2002-01-29 Thread Paul DuBois
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 get

Re: next insert id

2002-01-29 Thread Christopher Thompson
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

Re: next insert id

2002-01-29 Thread Paul DuBois
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 issue

Re: next insert id

2002-01-29 Thread laszlo
assuming id is the auto incremnt field. - Johnny Withers [EMAIL PROTECTED] p. 601.853.0211 c. 601.209.4985 -Original Message- From: Joel Wickard [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:04 PM To: [EMAIL PROTECTED] Subject: next insert id

Re: next insert id

2002-01-29 Thread James Montebello
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

Re: next insert id

2002-01-29 Thread 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. james montebello On Tue, 29 Jan 2002, Paul DuBois wrote: At 15:16 -0800 1/29/02, James Montebello wrote: SELECT MAX(id)

Re: next insert id

2002-01-29 Thread Christopher Thompson
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 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

RE: next insert id

2002-01-29 Thread Roger Baklund
* 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

Re: next insert id

2002-01-29 Thread Paul DuBois
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

Re: next insert id

2002-01-29 Thread Paul DuBois
Wickard [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 29, 2002 7:04 PM To: [EMAIL PROTECTED] Subject: next insert id 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

Re: next insert id

2002-01-29 Thread Paul DuBois
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 reliably

Re: next insert id

2002-01-29 Thread Paul DuBois
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. Then you

Re: next insert id

2002-01-29 Thread James Montebello
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

Re: next insert id

2002-01-29 Thread Paul DuBois
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 written