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? 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). 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
Archived
This topic is now archived and is closed to further replies.