Re: last_insert_id

2009-12-27 Thread Mark Goodge
Gary Smith wrote: Steve Edberg wrote: (2) autoincrement values are not reused after deletion, so if you deleted the record with ID=1000 inserted in (1), the next autoincrement would still be 1001, even if the existing records are IDs 1,2,3. This is usually the desired behavior, but again, may

Re: last_insert_id

2009-12-27 Thread Carsten Pedersen
Gary Smith skrev: ... An example of where it wouldn't be: Although ID is auto_increment, you could define a row as, say, '10005583429'. This would be a valid input. Selecting max(id) would return that number. However, auto_increment wouldn't change - it would still be '34' (or whatever) for t

Re: last_insert_id

2009-12-27 Thread Gary Smith
Steve Edberg wrote: (2) autoincrement values are not reused after deletion, so if you deleted the record with ID=1000 inserted in (1), the next autoincrement would still be 1001, even if the existing records are IDs 1,2,3. This is usually the desired behavior, but again, may not be what *you*

Re: last_insert_id

2009-12-27 Thread Victor Subervi
On Sun, Dec 27, 2009 at 1:30 PM, Gary Smith wrote: > Victor Subervi wrote: > >> On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman >> wrote: >> >> >> >>> last_insert_id() returns the last id auto-incremented in *the current >>> session*. If you disconnect and reconnect, it can not be retrieved. >

Re: last_insert_id

2009-12-27 Thread Steve Edberg
At 11:13 AM -0500 12/27/09, you wrote: Hi; mysql> select * from products; ++--+--+---++-+---++--++-+--+---+--+---+---++-

Re: last_insert_id

2009-12-27 Thread Gary Smith
Victor Subervi wrote: On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman wrote: last_insert_id() returns the last id auto-incremented in *the current session*. If you disconnect and reconnect, it can not be retrieved. Ahah! So how do I retrieve the last id inserted irrespective of co

Re: last_insert_id

2009-12-27 Thread Victor Subervi
On Sun, Dec 27, 2009 at 12:00 PM, Michael Dykman wrote: > last_insert_id() returns the last id auto-incremented in *the current > session*. If you disconnect and reconnect, it can not be retrieved. > Ahah! So how do I retrieve the last id inserted irrespective of connection? TIA, V

Re: last_insert_id

2009-12-27 Thread Michael Dykman
last_insert_id() returns the last id auto-incremented in *the current session*. If you disconnect and reconnect, it can not be retrieved. - michael dykman On Sun, Dec 27, 2009 at 11:42 AM, Victor Subervi wrote: > On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi wrote: > >> 2009/12/27 Victor Sub

Re: last_insert_id

2009-12-27 Thread Victor Subervi
On Sun, Dec 27, 2009 at 11:27 AM, Mattia Merzi wrote: > 2009/12/27 Victor Subervi : > > mysql> select * from products; > [...] > > mysql> select last_insert_id() from products; > [...] > > Now, I was expecting 1, not 0! What up? > > [...] LAST_INSERT_ID() (no arguments) returns the first > automat

Re: last_insert_id

2009-12-27 Thread Mattia Merzi
2009/12/27 Victor Subervi : > mysql> select * from products; [...] > mysql> select last_insert_id() from products; [...] > Now, I was expecting 1, not 0! What up? [...] LAST_INSERT_ID() (no arguments) returns the first automatically generated value successfully inserted for an AUTO_INCREMENT colum

Re: LAST_INSERT_ID and CRC32

2009-05-05 Thread thun...@isfahan.at
Thank you very much for all answers I will trying Triggers and the example with the update after an INSERT. Ant then, I use the best for me;-) Thunder Yes, Triggers... I so rarely use them I forget they exist. On Tue, May 5, 2009 at 10:22 AM, Thomas Pundt wrote: Johnny Withers schr

Re: LAST_INSERT_ID and CRC32

2009-05-05 Thread Johnny Withers
Yes, Triggers... I so rarely use them I forget they exist. On Tue, May 5, 2009 at 10:22 AM, Thomas Pundt wrote: > Johnny Withers schrieb: > >> Well, I think an update after insert is the only way. Other than >> perpopulating another table with possibe crc values then usinga join: >> >> Select id

Re: LAST_INSERT_ID and CRC32

2009-05-05 Thread Thomas Pundt
Johnny Withers schrieb: Well, I think an update after insert is the only way. Other than perpopulating another table with possibe crc values then usinga join: Select id from testtable Inner join crctable on testtable.id=crctable.id Where crctable.crcval='xxx' Just be sure to index the crcva

Re: LAST_INSERT_ID and CRC32

2009-05-03 Thread Johnny Withers
Well, I think an update after insert is the only way. Other than perpopulating another table with possibe crc values then usinga join: Select id from testtable Inner join crctable on testtable.id=crctable.id Where crctable.crcval='xxx' Just be sure to index the crcval column. On Sunday, Ma

Re: LAST_INSERT_ID and CRC32

2009-05-03 Thread thun...@isfahan.at
I'm so sorry for the mistake... I mean: I think it is to slow when I make a SELECT later in this form: I don't think its possible to do what you want in a single statement. Since LAST_INSERT_ID() is set to the last insert id of the connection... and the row you are inserting doesn't exist.. wel

Re: LAST_INSERT_ID and CRC32

2009-05-03 Thread thun...@isfahan.at
Hi Johnny, I need the CRC32 for a unique URL-ID... I think it isn't to slow when I make a SELECT later in this form: Rows in Table: 825,984 Search for id: 2532552 (CRC32: 46316330) SELECT id FROM `testtable` WHERE id = "2532552" 0.0005 sec. SELECT id FROM `testtable` WHERE CRC32(id) = "46316

Re: LAST_INSERT_ID and CRC32

2009-05-03 Thread Johnny Withers
I don't think its possible to do what you want in a single statement. Since LAST_INSERT_ID() is set to the last insert id of the connection... and the row you are inserting doesn't exist.. well.. until you create it, it will always either be zero or the record BEFORE your next insert, ie: INSERT I

Re: last_insert_id problem

2006-07-07 Thread John L Meyer
Afshad Dinshaw wrote: Hi Im using the latest version of mysql. When I run the following query : select last_insert_id() if get the error message: function vcontacts.last_insert_id does not exist note: vcontacts is the name of my database. anyone know why? thanks I can run it both upperca

Re: last_insert_id

2005-02-15 Thread mel list_php
me advice... From: Philippe Poelvoorde <[EMAIL PROTECTED]> Reply-To: "'mysql@lists.mysql.com '" To: mel list_php <[EMAIL PROTECTED]> CC: mysql@lists.mysql.com Subject: Re: last_insert_id Date: Tue, 15 Feb 2005 10:50:40 + mel list_php wrote: Hi! I have a database whe

Re: last_insert_id

2005-02-15 Thread mel list_php
ply-To: "'mysql@lists.mysql.com '" To: mel list_php <[EMAIL PROTECTED]> CC: mysql@lists.mysql.com Subject: Re: last_insert_id Date: Tue, 15 Feb 2005 10:50:40 + mel list_php wrote: Hi! I have a database where several users can connect and input data. I managed to have my

Re: last_insert_id

2005-02-15 Thread mel list_php
'" To: mel list_php <[EMAIL PROTECTED]> CC: mysql@lists.mysql.com Subject: Re: last_insert_id Date: Tue, 15 Feb 2005 10:50:40 + mel list_php wrote: Hi! I have a database where several users can connect and input data. I managed to have my insert queries as atomic, but I was wonderin

Re: last_insert_id

2005-02-15 Thread Philippe Poelvoorde
mel list_php wrote: Hi! I have a database where several users can connect and input data. I managed to have my insert queries as atomic, but I was wondering about one special case: I make one insert, and retrieve the last id inserted by mysql because I need to update an other table with that id.

Re: last_insert_id

2005-02-15 Thread Alec . Cawley
"mel list_php" <[EMAIL PROTECTED]> wrote on 15/02/2005 10:18:55: > Hi! > > I have a database where several users can connect and input data. > > I managed to have my insert queries as atomic, but I was wondering about one > special case: I make one insert, and retrieve the last id inserted by

Re: last_insert_id

2005-02-15 Thread Johan Höök
Hi, You can probably use "SELECT LAST_INSERT_ID()" which keeps auto-increment values on a per connection basis. See: http://dev.mysql.com/doc/mysql/en/getting-unique-id.html /Johan mel list_php wrote: Hi! I have a database where several users can connect and input data. I managed to have my insert

Re: last_insert_id() and load data infile

2004-12-25 Thread Gleb Paharenko
Hello. As said at: http://dev.mysql.com/doc/mysql/en/Information_functions.html "If you insert many rows at the same time with an insert statement, LAST_INSERT_ID() returns the value for the first inserted row." LOAD DATA INFILE inserts several rows a time, so this is a usual behavio

Re: last_insert_id() value not updated

2004-06-02 Thread Victoria Reznichenko
"paqogomez" <[EMAIL PROTECTED]> wrote: > I am trying to build a stored procedure in v. 5. > This is what I have so far. > > delimiter | > create procedure get_id(out oid int) > begin >insert into mercury.merchant (name) values(null); >select last_insert_id() into @mid; >insert into mer

RE: LAST_INSERT_ID() and Stored Procs

2004-04-22 Thread Matt Chatterley
Oh. If only I'd tried ONE more thing before mailing that out! If anyone does have the same problem, the vital (missing) piece of information is that I was using MySQLCC. It seems to have problems with SPs unless you open a new query window after changing the contents of a procedure.. Thanks, M

Re: last_insert_id()

2003-09-24 Thread Haydies
Don't forget that if you "commit" then last_insert_id will return 0 - Original Message - From: "William R. Mussatto" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, September 24, 2003 6:56 PM Subject: Re: last_insert_id() : R.Dobson sa

Re: last_insert_id()

2003-09-24 Thread William R. Mussatto
R.Dobson said: > Hi, > > Is it possible to obtain the last_insert_id() for a particular column in > a particular table? > eg, say i wanted to obtain the last insert id of a column called id in > table reference, something along the lines of: > > last_insert_id(reference.id) > > The reason I ask is

Re: LAST_INSERT_ID() returns different values on different connections

2003-06-24 Thread Paul DuBois
At 16:02 +0300 6/17/03, Baris Akin wrote: Hello, I try to get last inserted autoincrement record ID on table with LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every connection returns it's own last inserted ID not actual ID. Is this a bug? Also it returns more than one record

Re: LAST_INSERT_ID() returns different values on different connections

2003-06-17 Thread Victoria Reznichenko
"Baris Akin" <[EMAIL PROTECTED]> wrote: > LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every > connection returns it's own last inserted ID not actual ID. Is this a > bug? No. LAST_INSERT_ID() works per-connection. It returns the last inserted auto_increment value from current

Re: LAST_INSERT_ID() returns different values on different connections

2003-06-17 Thread Fred van Engen
On Tue, Jun 17, 2003 at 04:02:46PM +0300, Baris Akin wrote: > I try to get last inserted autoincrement record ID on table with > LAST_INSERT_ID() function (SELECT LAST_INSERT_ID() FROM TABLE). Every > connection returns it's own last inserted ID not actual ID. Is this a > bug? Also it returns more

Re: Re: last_insert_id() returns 0 in windows

2003-02-02 Thread Nasser Ossareh
Could it be that the table types are different? the innodb table types seem to ignore auto_increment while MyISAM are more accommodating... so it might be that your table on Linux is MyISAM type while the table on XP is Innodb type. --- Alan <[EMAIL PROTECTED]> wrote: > Okay, I've seen just a

Re: last_insert_id() returns 0 in windows

2003-02-02 Thread Dan Nelson
In the last episode (Feb 01), Alan said: > Okay, I've seen just about every question on last_insert_id(), except > this one: > > I am running MySQL on Win XP and when I generate a test table (test) > with an AUTO_INCREMENT column (aid) and a second column (a) then use > an insert statement like: I

Re: last_insert_id()

2002-11-12 Thread Joshua J . Kugler
This looks like the same problem I have with MS Access. It seems MS Access uses the SELECT id FROM table_name WHERE is IS NULL, and this syntax clears the last insert ID field. My solution is here: --- One Line URL, might wrap --- http://groups.google.com/groups?hl=en&safe=off&threadm=9ehc8i%2

RE: last_insert_id()

2002-11-12 Thread Alan McDonald
The .Neta Adapter.. does it make a persistent connection? If the connection drops between the first insert and the call to select, then the return would be zero Alan > -Original Message- > From: Cain O'Sullivan [mailto:cos@;iinet.net.au] > Sent: Wednesday, 13 November 2002 16:13 > To: [EM

Re: last_insert_id() question

2002-09-26 Thread Jeff Kilbride
Hi Sean, > "If expr is given as an arguement to LAST_INSERT_ID(), the value of the > arguement is returned by the function, is set as the next value to be > returned by LAST_INSERT_ID(), and is used as the next AUTO_INCREMENT > value" I don't think this entire statement is correct. The onlin

Re: last_insert_id questions

2002-09-20 Thread Paul DuBois
At 1:49 -0700 9/20/02, PR wrote: >I have a message board app I'm using where I'm trying to make the code >faster and more efficient than it is now. At times this board will >generate a lot of new posts to it very very quickly. In one section where >posts are added, after the post is made and ins

Re: last_insert_id() query

2002-04-24 Thread Gerald Clark
Don't include a from clause with the last_insert_id(), or you will get a full table scan. The last_insert_id will only give you the insert id for the last record inserted. mysql mailing list user wrote: > Hi, > I have a big problem with last_insert_id() query. > I am adding records to a tabl

Re: LAST_INSERT_ID()

2002-04-23 Thread Erik Price
On Tuesday, April 23, 2002, at 03:10 PM, destr0 wrote: > SELECT LAST_INSERT_ID() as id FROM myTable; > > It returns the last inserted Id, but why does it return that value for > every > row in the table. > > for example. > if there are 5 total records in the table. and the last inserted Id is

Re: LAST_INSERT_ID()

2002-04-23 Thread BD
At 02:10 PM 4/23/2002, you wrote: >query, table > >When I run the query: > >SELECT LAST_INSERT_ID() as id FROM myTable; > >It returns the last inserted Id, but why does it return that value for every >row in the table. > >for example. >if there are 5 total records in the table. and the last insert

Re: LAST_INSERT_ID()

2002-04-23 Thread Christopher Thompson
On Tuesday 23 April 2002 1:10 pm, destr0 wrote: > query, table > > When I run the query: > > SELECT LAST_INSERT_ID() as id FROM myTable; This query really makes no sense. It is almost the same as: SELECT LAST_INSERT_ID() as id; > It returns the last inserted Id, but why does it return that val

Re: last_insert_id gives 0

2002-04-08 Thread Kevin Donnelly
Hi Paul On Monday 08 April 2002 12:56 am, Paul DuBois wrote: > You're inserting a specific value into the AUTO_INCREMENT field, which > doesn't result in the creation of a new automatic sequence number. > > If you want to insert a record with a specific value in that column, *and* > you want the

Re: last_insert_id gives 0

2002-04-07 Thread Paul DuBois
>On Sun, 7 Apr 2002 19:56:47 -0500 >Paul DuBois <[EMAIL PROTECTED]> wrote: > >> >I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table >> >"customers" with an auto-incrementing primary key "customer_id". >>If I insert >> >a record: >> >mysql> insert into customers(custome

Re: last_insert_id gives 0

2002-04-07 Thread Dicky Wahyu Purnomo
On Sun, 7 Apr 2002 19:56:47 -0500 Paul DuBois <[EMAIL PROTECTED]> wrote: > >I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table > >"customers" with an auto-incrementing primary key "customer_id". If I insert > >a record: > >mysql> insert into customers(customer_id) values

Re: last_insert_id gives 0

2002-04-07 Thread Paul DuBois
>I am running MySQL 3.23.41-17 on a stock SuSE 7.3 install. I have a table >"customers" with an auto-incrementing primary key "customer_id". If I insert >a record: >mysql> insert into customers(customer_id) values ("10"); >and then ask for the last insert: >mysql> select last_insert_id(); >(whic

Re: Last_Insert_Id() returning 0

2002-02-01 Thread Jason Yates
> I am doing this using mySQlGui 1.7.5-2 on Win 2000 > Professional. >From what I understand last_insert_id() can only be used on the same connection as the insert. I'm guessing after every query mysqlgui runs it disconnects, therefore killing last_insert_id(). -Jason Yates ---

Re: last_insert_id() bug ?? using INSERT IGNORE

2001-10-01 Thread marcus davy
On Tue, 02 Oct 2001 14:37, Paul DuBois wrote: > At 10:45 AM +1200 10/2/01, marcus davy wrote: > >On Mon, 01 Oct 2001 14:44, Paul DuBois wrote: > >> At 11:44 AM +1200 10/1/01, marcus davy wrote: > >> >If you specify the keyword IGNORE in an INSERT, any rows that > >> > duplicate an existing PRIM

Re: last_insert_id() bug ?? using INSERT IGNORE

2001-10-01 Thread Paul DuBois
At 10:45 AM +1200 10/2/01, marcus davy wrote: >On Mon, 01 Oct 2001 14:44, Paul DuBois wrote: >> At 11:44 AM +1200 10/1/01, marcus davy wrote: >> >If you specify the keyword IGNORE in an INSERT, any rows that duplicate >> >an existing PRIMARY or UNIQUE key in the table are ignored and are not >>

Re: last_insert_id() bug ?? using INSERT IGNORE

2001-10-01 Thread marcus davy
On Mon, 01 Oct 2001 14:44, Paul DuBois wrote: > At 11:44 AM +1200 10/1/01, marcus davy wrote: > >If you specify the keyword IGNORE in an INSERT, any rows that duplicate > >an existing PRIMARY or UNIQUE key in the table are ignored and are not > >inserted. > >But the last_insert_id() function still

Re: last_insert_id() bug ?? using INSERT IGNORE

2001-10-01 Thread Benjamin Pflugmann
ere the last record violates a unique key and therefore has to be ignored, and if one wants to use that last value - although that a rather special case. Bye, Benjamin. > > Will French > > > -Original Message- > > From: Paul DuBois [mailto:[EMA

RE: last_insert_id() bug ?? using INSERT IGNORE

2001-09-30 Thread Will French
-Original Message- > From: Paul DuBois [mailto:[EMAIL PROTECTED]] > Sent: Sunday, September 30, 2001 10:45 PM > To: marcus davy; [EMAIL PROTECTED] > Subject: Re: last_insert_id() bug ?? using INSERT IGNORE > > > At 11:44 AM +1200 10/1/01, marcus davy wrote: > >

Re: last_insert_id() bug ?? using INSERT IGNORE

2001-09-30 Thread Paul DuBois
At 11:44 AM +1200 10/1/01, marcus davy wrote: >If you specify the keyword IGNORE in an INSERT, any rows that duplicate >an existing PRIMARY or UNIQUE key in the table are ignored and are not >inserted. >But the last_insert_id() function still appears to increment by one >in situations when the que

Re: LAST_INSERT_ID()

2001-08-22 Thread Werner Stürenburg
Curtis Maurand schrieb am Mittwoch, 22. August 2001, 21:17:40: > A caveat is that you get the last_insert_id for your connection. Not the > last one in the database. I'm puzzled. There is no last_insert_id of the database, only of a certain table, and it is indeed the one last manipulated. S

Re: LAST_INSERT_ID()

2001-08-22 Thread Curtis Maurand
A caveat is that you get the last_insert_id for your connection. Not the last one in the database. Curtis On Wed, 22 Aug 2001, Dr. Werner Stürenburg wrote: > > > Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 14:57:06: > > > At 13:19 22.8.2001 +0200, you wrote: > >>LAST_INSERT_ID() should

Re: LAST_INSERT_ID()

2001-08-22 Thread Dr. Werner Stürenburg
Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 14:57:06: > At 13:19 22.8.2001 +0200, you wrote: >>LAST_INSERT_ID() should return the last autoincrement value of >>the last insert > Yep it sure did, managed to get to machine and test it out. Total mess. > but; > $query = "SELECT LAST_INSER

Re: LAST_INSERT_ID()

2001-08-22 Thread Jari Mäkelä
At 13:19 22.8.2001 +0200, you wrote: >LAST_INSERT_ID() should return the last autoincrement value of >the last insert Yep it sure did, managed to get to machine and test it out. Total mess. but; $query = "SELECT LAST_INSERT_ID()"; $result = mysql_query($query); if ($result) { $nrows = mysql_num

Re: LAST_INSERT_ID()

2001-08-22 Thread Dr. Werner Stürenburg
Jari Mäkelä schrieb am Mittwoch, 22. August 2001, 11:31:01: > Hi, > in the manual there is this LAST_INSERT_ID() and it is what I actually need > but there is some confusion over how to use it in many tables. > http://www.mysql.com/doc/O/D/ODBC_and_last_insert_id.html> > Or, if you are just

Re: last_insert_id() issue w/ DBI

2001-06-12 Thread Erik Rantapaa
On Tue, Jun 12, 2001 at 04:47:47PM -0500, Paul DuBois wrote: > > Try using: > > $dbh->do ("UPDATE ... WHERE k = ?", undef, "xxx") > and then access $dbh->{mysql_insertid} to see if you get a different > result. I suspect perhaps not, but it's something to try. Unfortunately I get the same resu

Re: last_insert_id() issue w/ DBI

2001-06-12 Thread Paul DuBois
At 4:34 PM -0500 6/12/01, Erik Rantapaa wrote: >This really might be a DBI problem, but I find it's pretty weird. > >I am attempting to perform atomic updates by using UPDATE statements >like: > > UPDATE counter SET v = last_insert_id(v+1) WHERE k = 'xxx'; > >where counter has the schema: cr

RE: LAST_INSERT_ID Issues

2001-05-25 Thread Dave Carter
; [EMAIL PROTECTED] Subject: Re: LAST_INSERT_ID Issues At 9:48 AM -0400 5/25/01, Dave Carter wrote: >This does not return any results > >SELECT LAST_INSERT_ID() FROM tablename; It doesn't return *any* results? Or do you mean it returns 0? FROM tablename is superfluous here; t

RE: LAST_INSERT_ID Issues

2001-05-25 Thread Paul DuBois
query > >-Original Message- >From: Billy Passauer [mailto:[EMAIL PROTECTED]] >Sent: Friday, May 25, 2001 10:18 AM >To: Dave Carter >Subject: RE: LAST_INSERT_ID Issues > > >> -Original Message- >> From: Dave Carter [mailto:[EMAIL PROTECTED]] >&

Re: LAST_INSERT_ID Issues

2001-05-25 Thread Paul DuBois
At 9:48 AM -0400 5/25/01, Dave Carter wrote: >This does not return any results > >SELECT LAST_INSERT_ID() FROM tablename; It doesn't return *any* results? Or do you mean it returns 0? FROM tablename is superfluous here; the most recent AUTO_INCREMENT value is maintained on a per-connection basi

RE: LAST_INSERT_ID Issues

2001-05-25 Thread Dave Carter
://www.abti.cc 717.464.2970 Filter Lovin: sql, database, query -Original Message- From: Billy Passauer [mailto:[EMAIL PROTECTED]] Sent: Friday, May 25, 2001 10:18 AM To: Dave Carter Subject: RE: LAST_INSERT_ID Issues > -Original Message- > From: Dave Carter [mailto:[EMAIL PRO

RE: LAST_INSERT_ID Issues

2001-05-25 Thread Proulx, Ghislain
Hello Dave, If your auto-incrementing field in your table are Account_ID for exemple, try : Select Account_ID From tablename Where Account_ID = LAST_INSERT_ID(); This work fine for me Bye Ghislain Proulx Web Programmer Groupe Ordimax http://www.ordimax.com http://www.infoteck.qc.ca > -O

Re: LAST_INSERT_ID returning 3 rows?

2001-05-03 Thread Alexander Skwar
So sprach Graeme B. Davis am Tue, May 01, 2001 at 01:09:15PM -0400: > Ok I was thinking that you had to tell LAST_INSERT_ID the table you wanted > to get the last insert id from. What if you run a web site and you have 10 > tables in a database, how can you tell what the last insert id of table 6

Re: LAST_INSERT_ID returning 3 rows?

2001-05-02 Thread alec . cawley
> COk I was thinking that you had to tell LAST_INSERT_ID the table you wanted > to get the last insert id from. What if you run a web site and you have 10 > tables in a database, how can you tell what the last insert id of table 6 > was? As I understand it, LAST_INSERT_ID is connection based, n

Re: LAST_INSERT_ID returning 3 rows?

2001-05-01 Thread Graeme B. Davis
Ok now I understand -- it's on a per-connection basis =) thanks, graeme - Original Message - From: "Graeme B. Davis" <[EMAIL PROTECTED]> To: "Gerald Clark" <[EMAIL PROTECTED]>; "Braxton Robbason" <[EMAIL PROTECTED]> Cc: <[EMAIL PRO

Re: LAST_INSERT_ID returning 3 rows?

2001-05-01 Thread Graeme B. Davis
Ok I was thinking that you had to tell LAST_INSERT_ID the table you wanted to get the last insert id from. What if you run a web site and you have 10 tables in a database, how can you tell what the last insert id of table 6 was? Thanks, Graeme > Because you included a from clause, you got one

Re: LAST_INSERT_ID returning 3 rows?

2001-04-30 Thread Gerald Clark
Because you included a from clause, you got one line for each row of 'outages' Leave out the "from outages" Graeme B. Davis wrote: > mysql> INSERT INTO outages (status) VALUES ('Open'); > mysql> SELECT LAST_INSERT_ID() AS lid FROM outages; > +-+ > | lid | > +-+ > | 101 | > | 101 | > | 1

RE: LAST_INSERT_ID returning 3 rows?

2001-04-30 Thread Braxton Robbason
last_insert_id is a function. It will return a value for each row in the table. You want to run: select last_insert_id() as lid; instead of selecting from a table. -Original Message- From: Graeme B. Davis [mailto:[EMAIL PROTECTED]] Sent: Monday, April 30, 2001 3:17 PM To: [EMAIL PROTECT

Re: Last_Insert_ID ()

2001-03-31 Thread Fred van Engen
On Sat, Mar 31, 2001 at 10:11:33PM +0530, P.V. Sajan wrote: > Helllo All !! > > I 've a problem i want to retrieve the primary key value of the last > Inserted record in a table and use it in another table. > > I did > select Last_Insert_Id () from trans ; What you were doing is like: select 1