balamberas Posted June 25, 2009 Share Posted June 25, 2009 How do you tie two tables in MySQL? im inserting data into two tables using one html form. user table and flats table. But how do you make user_id in the flats table a foreign key? how do that auto_increment after inserting data? Quote Link to comment https://forums.phpfreaks.com/topic/163612-how-do-you-tie-two-tables-in-mysql/ Share on other sites More sharing options...
gevans Posted June 25, 2009 Share Posted June 25, 2009 These are setting that should be put in place when initially setting up your db. If you don't already have auto increment set up, then run the following; ALTER TABLE `table_name` CHANGE `field_name` `field_name` INT( 11 ) NOT NULL AUTO_INCREMENT Replace INT( 11 ) NOT NULL with your settings. For a foreign key you must be using an InnoDB table (for both). Quote Link to comment https://forums.phpfreaks.com/topic/163612-how-do-you-tie-two-tables-in-mysql/#findComment-863276 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.