Parth Bhatt Parth Bhatt - 6 months ago 28
MySQL Question

How to add relationships between tables in existing MySQL database?

I have a existing MySQL database which has large number of tables.

But the problem is the relationships between the tables has not been added. How can I add relationships between tables in my existing MySQL database?

Answer Source

something like this

ALTER TABLE `table1` ADD CONSTRAINT table1_id_refs FOREIGN KEY (`table2_id`) REFERENCES `table2` (`id`);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download