Page 1 of 1
auto_increment
Posted: Tue Jun 21, 2005 1:41 pm
by Parody
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?
Posted: Tue Jun 21, 2005 1:43 pm
by hawleyjr
mysql_insert_id
Re: auto_increment
Posted: Tue Jun 21, 2005 7:51 pm
by Chris Corbyn
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?
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....
Posted: Wed Jun 22, 2005 8:02 am
by zippee
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.
Posted: Wed Jun 22, 2005 8:15 am
by shiznatix
zippee 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.
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 time
Posted: Wed Jun 22, 2005 4:06 pm
by Parody
I read all of this and I managed to gather some info, thanks
BTW the id only needs to be unique in one of the tables, so am i right in saying I must insert the id here and use the function that was mention first?