ameliabob Posted December 5, 2014 Share Posted December 5, 2014 Is there a way without doing an additional search to find the number of an inserted row immediately after it has been added? I need to reference a row with rows immediately after it when inserting data into the data base. e.g insert Header Row insert detail row with a link back to Header Row insert detail row with a link back to Header Row insert detail row with a link back to Header Row So the table would be ID Link Contents 1 0 Header 2 1 Detail1 3 1 Detail2 4 1 Detail2 Link to comment Share on other sites More sharing options...
justsomeguy Posted December 5, 2014 Share Posted December 5, 2014 Yes, each database has a way to get the identity value that was just created. Look up the documentation for the database you're using to see how it does it. Link to comment Share on other sites More sharing options...
ameliabob Posted December 7, 2014 Author Share Posted December 7, 2014 I looked in the mysql area and couldn't find any desription on how to use it??? Link to comment Share on other sites More sharing options...
davej Posted December 7, 2014 Share Posted December 7, 2014 This sounds quite squirrely to me. I think it breaks some rules of table normalization, because you are throwing dependencies into the table. http://en.wikipedia.org/wiki/Database_normalization You would need to look at transactions and probably stored procedures. (edited Dec08 9:05am) Link to comment Share on other sites More sharing options...
JamesB Posted December 7, 2014 Share Posted December 7, 2014 http://php.net/manual/en/mysqli.insert-id.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now