mysql - Migrating data from an old to a new schema -
mysql - Migrating data from an old to a new schema -
i have 2 tables 2 different schemas. want move info table in old schema table in new schema.
set foreign_key_checks = 0; insert newdb.addresses (addressid, contactid, primaryflag, type, address1, address2, pobox, city, state, zip, country, email) select address_id, contact_id, is_primary_address, (select address_type test.address_types, test.contact_addresses test.contact_addresses.address_type_id = test.address_types.address_type_id), address_line_1, address_line_2, address_line_2, address_city, address_state, address_zip, (select country test.countries, test.contact_addresses test.contact_addresses.address_country_id = test.countries.country_id), address_email test.contact_addresses;
sorry if it's sloppily typed. basically, when run query, says subquery returns more 1 row. how restructure query returned in subqueries row engine iterating through (therefore, 1 row returned)?
you dont need test.contact_addresses in subqueries:
select address_id, contact_id, is_primary_address, (select address_type test.address_types @ at.address_type_id = ca.address_type_id), address_line_1, .... test.contact_addresses ca;
this way, sql selects 1 equals adress_type_id in outer query.
mysql database migration database-migration
Comments
Post a Comment