mySQL / Last inserted record ID

Ask a Question related to ASP, Design and Development.

  1. #1

    Default 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


    Richard N. Guest

  2. Similar Questions and Discussions

    1. Inserting a timestamp when record is inserted
      Hi, how would I have a form insert a timestamp when the form was submitted for update into a table. I know there is a timestamp column type but I...
    2. ID of last record inserted
      Is it possible, with a MS Access database, to pull the ID of a record just inserted? I have found various threads and tutorials on various sites...
    3. Accepted way to grab the ID of a record you have just inserted?
      I have a page that inserts a new record into a DB. Upon doing so, I want to refresh the page and return the data that was just entered (including...
    4. Identity from inserted record
      I'm inserting a record into a SQL Server database. Once the record has been added, I need the Identity value that SQL Server created. Normally, the...
    5. returning an inserted SQL record
      Found my answer... Select max(column) as ID from table
  3. #2

    Default Re: mySQL / Last inserted record ID

    "Richard N." <richard@NOSPAMPLEASEbrandlink.co.uk> wrote in message
    news:bn11n5$lk6$1@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
    [url]http://www.kamath.com/tutorials/tut007_identity.asp[/url]

    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



    Peter Foti Guest

  4. #3

    Default Re: mySQL / Last inserted record ID

    <snip>
    > > strLastID = objConn.Execute("SELECT LAST_INSERT_ID() FROM sentmessages")
    >
    > SQL Server has @@IDENTITY
    > [url]http://www.kamath.com/tutorials/tut007_identity.asp[/url]
    >
    > 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


    Richard N. Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139