Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    2

    Unanswered: 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

  2. #2
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •