Problem with auto increment primary key (MySQL).
Posted
by mathon12
on Stack Overflow
See other posts from Stack Overflow
or by mathon12
Published on 2010-05-16T14:10:04Z
Indexed on
2010/05/16
14:20 UTC
Read the original article
Hit count: 265
I have 2 tables each using other's primary key as a foreign key. The primary keys for both are set to auto_increment
.
The problem is, when I try to create and entry into one of the tables, I have no idea what the primary key of the entry is and can't figure out what to put in the other table as a foreign key. What should I do? Do I drop auto_increment altogether and cook up a unique identifier for each entry so I can use it to address the created entries? I'm using PHP, if that's relevant. Thanks.
© Stack Overflow or respective owner