auto_increment
Moderator: General Moderators
auto_increment
i'm using the auto_increment option for mysql to generate an id for a group of people, this needs to be outputted to a main database and 4 other tables. how do i make sure it is the same id for all?
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Re: auto_increment
Mind if I ask why it needs to be the same in the other 4 tables even when inserted? I think we could add a few columns to your tables to eliminate this need if I'm thinking the right thing about why you need this....Parody wrote:i'm using the auto_increment option for mysql to generate an id for a group of people, this needs to be outputted to a main database and 4 other tables. how do i make sure it is the same id for all?
I normally create another field like 'my_id' after the auto_increment 'id' to have better control. I generate the 'my_id' based on date, ip &/or random number.
Note that you cannot search the database based on the auto_increment 'id' value, like $query = "SELECT * FROM table WHERE id = '$id' "; This will give you error.
Note that you cannot search the database based on the auto_increment 'id' value, like $query = "SELECT * FROM table WHERE id = '$id' "; This will give you error.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
noooo if the auto_increment field is named 'id' then if i did that search it would not give you a error, i do it all the timezippee wrote: Note that you cannot search the database based on the auto_increment 'id' value, like $query = "SELECT * FROM table WHERE id = '$id' "; This will give you error.