473,495 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 14745
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
41925
by: Sugapablo | last post by:
Let's say I create a new record in a table like this: mysql_query("INSERT INTO table (col1) VALUES ('example')",$conn); ....that had an auto-incrementing, unique identifying column named "ID"...
4
5032
by: sinasalek | last post by:
i have a problem with MySQL 4.1.x and UTF8. in version 4.0, i'm using html forms with utf8 charset for inserting unicode strings. but in version 4.1.x it is not working! if i change the charset of...
3
12503
by: Bob Bedford | last post by:
Does it exits a mysql or PHP function to know the last updated id record ? When you perform an insert you can know the last inserted ID. In my case I'd like the same with the last updated. I'm...
1
8727
by: PT | last post by:
I got a problem. And thats..... First of all, I got these three tables. ------------------- ------------------ ---------------------- tblPerson tblPersonSoftware ...
24
2105
by: Ehud Shabtai | last post by:
Hi, I would like to store samples of data which are gathered from about 500 devices in mysql. Each device has its own data which changes over time. The data may be integer or float. The...
0
3923
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest...
1
3006
by: djmeltdown | last post by:
I'm having trouble getting a foreach() loop to insert a record into a MySQL Database. Which I've never had any trouble before, it just seems quirky. I've tried the mysql_query statement without a...
6
3772
by: Skygal | last post by:
Hello - beginner here... I'm trying to insert records into a mysql db that are entered from an html form. I'm not getting any errors, but the insert isn't working. Am I missing something obvious?...
1
9547
ssnaik84
by: ssnaik84 | last post by:
Hi Guys, Last year I got a chance to work with R&D team, which was working on DB scripts conversion.. Though there is migration tool available, it converts only tables and constraints.. Rest of...
0
7120
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6991
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6878
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7373
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4897
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
649
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.