You basically need to keep track the new and old id from mo_sms
- load all DB2.mo_sms that you want to copy
- for each row in this result set
- store the actual DB2.mo_sms id
- save this row on DB1.mo_sms
- store the new DB1.mo_sms id, you can use LAST_INSERT_ID()
- load all DB2.mt_sms entries related to id that you stored on step 2.1
- save all entries on DB1.mt_sms changing the mt_sms.id_MO to the new id received on DB1 (the one which you stored on 2.3)
This should work.
Edit 1:
#Edit 1: YouYou can do it using an external programming language or stored procedure, if you choose to use a stored procedure, you will need to deal with cursors