defenseman
[H]ard|Gawd
- Joined
- Nov 20, 2000
- Messages
- 1,738
I like to give my tables an 'id' field which serves as each row's unique identifier/primary key (no other foreign keys or indexes).
My question is, whats the best way for obtaining that row's 'id' field after adding the item with auto-increment (meaning I don't specify the new row's id when adding the row)?
I could try and search for that row via other columns right after I add it, but that won't always give me the row that was just added because two or more rows could have that same data.
I could also try and figure out the new row's id field before adding the item, but that's not perfect either if I have a large number of users adding data to the database as the 'same' time.
My question is, whats the best way for obtaining that row's 'id' field after adding the item with auto-increment (meaning I don't specify the new row's id when adding the row)?
I could try and search for that row via other columns right after I add it, but that won't always give me the row that was just added because two or more rows could have that same data.
I could also try and figure out the new row's id field before adding the item, but that's not perfect either if I have a large number of users adding data to the database as the 'same' time.