Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. [need help] mysql question [modified]

[need help] mysql question [modified]

Scheduled Pinned Locked Moved Web Development
questiondatabasephpmysqlhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam 2006
    wrote on last edited by
    #1

    hi all, i'm creating a site using php and a mysql database. i have a query that will look something like INSERT INTO table (value1, value2) VALUES ('...', '...'). the table 'table' has an auto-increment int 'id' field. how can i get the id of the row i just inserted, without SELECTing the row using WHERE value1='...' AND value2='...'? thanks in advance. -- modified at 10:10 Sunday 20th August, 2006

    G 1 Reply Last reply
    0
    • S Sam 2006

      hi all, i'm creating a site using php and a mysql database. i have a query that will look something like INSERT INTO table (value1, value2) VALUES ('...', '...'). the table 'table' has an auto-increment int 'id' field. how can i get the id of the row i just inserted, without SELECTing the row using WHERE value1='...' AND value2='...'? thanks in advance. -- modified at 10:10 Sunday 20th August, 2006

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Use the query "select last_insert_id()" on the same connection that you used to insert the record, and you get the id.

      --- b { font-weight: normal; }

      S 1 Reply Last reply
      0
      • G Guffa

        Use the query "select last_insert_id()" on the same connection that you used to insert the record, and you get the id.

        --- b { font-weight: normal; }

        S Offline
        S Offline
        Sam 2006
        wrote on last edited by
        #3

        i just did a search on "last_insert_id" and found this: http://us3.php.net/manual/en/function.mysql-insert-id.php thanks for the reply!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups