MySQL Forums
Forum List  »  General

Re: JOIN BETWEEN 2 TABLES WITH DIFFERENT ID COUNTING
Posted by: Rick James
Date: November 29, 2015 11:46AM

Bad design. Don't expect two AUTO_INCREMENTs to stay in sync.

If you want one id to match another, then don't make it AUTO_INCREMENT. Instead copy the value in. Such as

$id = SELECT id FROM table1 WHERE name = $name;
INSERT INTO table2 (id, ...) VALUES ($id, ...);

Options: ReplyQuote


Subject
Written By
Posted
Re: JOIN BETWEEN 2 TABLES WITH DIFFERENT ID COUNTING
November 29, 2015 11:46AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.