plastik77 Posted July 26, 2007 Share Posted July 26, 2007 Hi - is there a way to securely retrieve the primary key of the record you have just created, perhaps using @@Identity? I'm unfamiliar as i'm newish to SQL....I'm basically trying to run a php script which inserts data into a table, where the prim key is auto incremented. I then need to access the prim key of the newly created record. Haven't found a satisfactory way to do this so far, as to simply retrieve the newest record created would not account for the possibility that another user may have also just inserted a new row in the same table. Grateful for any help. Quote Link to comment https://forums.phpfreaks.com/topic/61891-solved-retrieving-the-primary-key-of-the-record-ive-just-created/ Share on other sites More sharing options...
Illusion Posted July 26, 2007 Share Posted July 26, 2007 LAST_INSERT_ID() is of interest but it won't work for DELAYED rows. Quote Link to comment https://forums.phpfreaks.com/topic/61891-solved-retrieving-the-primary-key-of-the-record-ive-just-created/#findComment-308180 Share on other sites More sharing options...
plastik77 Posted July 30, 2007 Author Share Posted July 30, 2007 thanks for the reply - i've decided to go with mysql_insert_id() Quote Link to comment https://forums.phpfreaks.com/topic/61891-solved-retrieving-the-primary-key-of-the-record-ive-just-created/#findComment-310761 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.