Id question

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Id question

Post by user___ »

I have two tables. One used for titles, lang, category, and id. The other has its own id and conten columns. Both ids are auto_increment so I wonder if a user enters a news and it is written in the tables, which are MyISAM, whether the ids will be the same as long as they are MyISAM and they do not support row locking.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

If there is only ever one user entering data then the will probably stay the same. A better solution would be to add a field to the second table that contains the ID of the record in the first table. You can then join on first.id=second.first_id
(#10850)
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Reply

Post by user___ »

I have an id in the second table so I should just remove the auto_increment and in the insert statement write what you have written. Am I right?
Post Reply