If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Get last item added

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-04-04, 18:43
dalyboy dalyboy is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
Get last item added

Hi,

I'm using JDBC and was wondering...How do i get the value of a primary key field (AUTO_INCREMENT)that was last added so I can display a confirmation on the screen? I've read on some places it can be done using php, so i would imagine it can be done with JDBC.

The primary key field acts as a member_id and I want to display a confirmation screen when it is added to the DB successfully (e.g <member_id> added to database successfully etc). Other fields would be uselful too but the primary key is my main concern at the mo.

Thanks,

Dalyboy
Reply With Quote
  #2 (permalink)  
Old 05-05-04, 01:52
snorp snorp is offline
Registered User
 
Join Date: Apr 2004
Location: Europe->Sweden->Stockholm
Posts: 71
You can always SELECT LAST_INSERT_ID(). If you insert many rows at the same time with an insert statement, LAST_ INSERT_ID() returns the value for the first inserted row.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On