469,951 Members | 2,619 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,951 developers. It's quick & easy.

mySQL / Last inserted record ID

Hi,

I'm using mySQL and wanted to get the ID of the record that I have just
inserted in to the table (sentmessages). There is a function in mySQL that
appears to be able to perform this task but I am not having any luck in
getting it to work.

Anybody else tried, successfully or not, to use this ?

The function is called LAST_INSERT_ID() and I have tried to implement it as
follows :

strLastID = objConn.Execute("SELECT LAST_INSERT_ID() FROM sentmessages")
Thanks

Richard
Jul 19 '05 #1
2 14586
"Richard N." <ri*****@NOSPAMPLEASEbrandlink.co.uk> wrote in message
news:bn**********@hercules.btinternet.com...
Hi,

I'm using mySQL and wanted to get the ID of the record that I have just
inserted in to the table (sentmessages). There is a function in mySQL that
appears to be able to perform this task but I am not having any luck in
getting it to work.

Anybody else tried, successfully or not, to use this ?

The function is called LAST_INSERT_ID() and I have tried to implement it as follows :

strLastID = objConn.Execute("SELECT LAST_INSERT_ID() FROM sentmessages")


SQL Server has @@IDENTITY
http://www.kamath.com/tutorials/tut007_identity.asp

But I don't know if mySQL supports that. Search the manual for IDENTITY. I
think there is some form of this, but I'm not sure what exactly it looks
like.

HTH.
Peter Foti

Jul 19 '05 #2
<snip>
strLastID = objConn.Execute("SELECT LAST_INSERT_ID() FROM sentmessages")
SQL Server has @@IDENTITY
http://www.kamath.com/tutorials/tut007_identity.asp

But I don't know if mySQL supports that. Search the manual for IDENTITY.

I think there is some form of this, but I'm not sure what exactly it looks
like.

HTH.
Peter Foti


So does mySQL apparently ! Works great thanks.......

Richard
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Sugapablo | last post: by
4 posts views Thread by sinasalek | last post: by
3 posts views Thread by Bob Bedford | last post: by
24 posts views Thread by Ehud Shabtai | last post: by
reply views Thread by Mike Chirico | last post: by
6 posts views Thread by Skygal | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.