我找到了一些选项来运行 mysql 查询以将一个表迁移/拆分为 2 个新表,但是我想在新表上创建的字段之一必须与另一个新表中的字段相同:
因此,从“From_payments”表中,我想创建两个名为“To_paymenttransaction”和“To_paymentinfo”的新表。许多字段是预定义的,有些来自旧表。唯一的问题是预定义字段“paymentinfoid”必须与两个新表相同。
**To_paymenttransaction** --- < --- **From_payments**
paymenttransactionid ------- < --- (Generate next available number in this column)
paymentinfoid -------------- < --- (Generate next available number in this column)
transactionid --------------- < --- txn_id
state ---------------------- < --- (Set all to "1")
amount -------------------- < --- mc_gross
currency ------------------- < --- mc_currency
dateline -------------------- < --- payment_date
paymentapiid --------------- < --- (Set all to "1")
request -------------------- < --- (Set all to "NULL")
reversed ------------------- < --- (Set all to "0")
**To_paymentinfo** -----------<
paymentinfoid -------------- < --- (Same generated number that goes to the paymentinfoif field in To_paymenttransaction table )
hash ----------------------- < --- (Set all to "Imported")
subscriptionid --------------- < --- (Set all to "1")
subscriptionsubid ------------ < --- ("2" IF above field mc_gross is 4, "1" IF above field mc_gross is 6, "0" IF above field mc_gross is 10)
userid ---------------------- < --- userid
completed ------------------ < --- (Set all to "0")
有任何想法吗?
非常感谢所有帮助。