Aaron wrote:
How can I select the last record that was inserted? An ASP/VB example would
be great too!
I believe you have it already.
I use:
select last_insert_id() as MyID
but from memory @@identity is a synonym of last_insert_id()
Dan
--
sig
Daniel Kasak
IT Developer
NUS
My Aaron,
I don´t know any means to get the last inserted record into a MySQL table,
as built-in command.
What I would do to get this record is to have a timestamp field in the
record (mmddmilisecsinday) to solve the problem.
That´s it.
Leandro Neves.
- Original Message -
From:
Rough example. Assuming that you are using the same connection since
last_insert_id() is connection specific.
rset.open INSERT INTO table1 values(someValue)
rset.open SELECT last_insert_id() as identity
identity = rset.fields(identity)
-Original Message-
From: Aaron
To: [EMAIL
Great - thanks!
-Original Message-
From: Victor Pendleton [mailto:[EMAIL PROTECTED]
Sent: March 10, 2004 5:36 PM
To: 'Aaron '; '[EMAIL PROTECTED] '
Subject: RE: @@identity
Rough example. Assuming that you are using the same connection since
last_insert_id() is connection specific
Hi,
I think what you need is an auto increment (primary key) column. When a
record is inserted, it will automatically generate the next number in the
sequence. Being a primary key, the column must be unique (i.e no two rows
can be the same), so you can identify a specify record in the table.
This may not be the correct solution exactly, but what I do to ensure that I
get the correct ID back is the following:
I know what I just inserted, therefore I can use this information in a WHERE
clause to ensure retrieving the correct ID.
Example: INSERT name='scott', age=20 into
: Wednesday, June 18, 2003 12:59 PM
To: 'Jonas Geiregat'; 'Mysql'
Subject: RE: @@identity
This may not be the correct solution exactly, but what I do to ensure that I
get the correct ID back is the following:
I know what I just inserted, therefore I can use this information in a WHERE
clause to ensure
On Wednesday 18 June 2003 13:59, Carter, Scott wrote:
This may not be the correct solution exactly, but what I do to ensure that
I get the correct ID back is the following:
I know what I just inserted, therefore I can use this information in a
WHERE clause to ensure retrieving the correct ID.
One should always use the
LAST_INSERT_ID() or after an insert, select max(id) from myTable.
Select max(id) from myTable should never be used to get the last insert id.
On a high traffic table you are not guaranteed it will be the ID for the
record you just inserted, another could have been
On 18-Jun-2003 Jonas Geiregat wrote:
I'm using php + mysql for my project
I want to get the last insert ID.
I could use the php function mysql_last_id();
but I could aslo use @@identity.
Now some people have advised me NOT to use @@identity, cause it's not
save buggy sometimes slow ..
is
Don Read wrote:
On 18-Jun-2003 Jonas Geiregat wrote:
I'm using php + mysql for my project
I want to get the last insert ID.
I could use the php function mysql_last_id();
but I could aslo use @@identity.
Now some people have advised me NOT to use @@identity, cause it's not
save buggy sometimes
Even the last_insert_id() returns 0
is it coz the table type is INNODB
- Original Message -
From: Jan Peuker [EMAIL PROTECTED]
To: Arul [EMAIL PROTECTED]
Sent: Friday, June 21, 2002 4:16 PM
Subject: Re: @@IDENTITY
You are using M$-Syntax, in MySQL you should use:
SELECT
Subject: Re: @@IDENTITY
You are using M$-Syntax, in MySQL you should use:
SELECT last_insert_id()
http://www.mysql.com/doc/e/x/example-AUTO_INCREMENT.html
regards,
jan
- Original Message -
From: Arul
To: MySQL
Sent: Friday, June 21, 2002 12:17 PM
Subject
-Original Message-
From: Richard Davidson [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 29, 2002 1:31 PM
To: MySql List; [EMAIL PROTECTED]
Subject: FYI: @@IDENTITY
I don't know if this is just weirdness on my system but I
thought I would
pass this on in case anyone runs
14 matches
Mail list logo