Parth Bhatt Parth Bhatt - 1 month ago 9
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`);