I have a large table that I’m trying to break up. For example I have a table called CONTACTS with a PK of ContactID and inside are fields for Addresses (AddressLine1, AddressLine2, State, etc..) and I want to move these addresses to their own table and have a PK/FK relationship.
I’ve already created my ADDRESSES table and created all the fields, including the FK for my PK ContactID in my CONTACTS table.
What method (query) is the best way of copying the address data to the new table (including the PK to the FK field)? Documentation on the procedure would be greatly appreciated (I’m not looking for someone to write the whole query for me if it is long).
Thanks!
I’d suggest
INSERT INTO ... SELECT ...http://dev.mysql.com/doc/refman/5.5/en/insert-select.html