我想将一些行数据复制到另一个表中,例如:
我有两张桌子:(qa_items_purchases),(qa_suppliers_invoices
qa_items_purchases,数据:
qa_suppliers_invoices为空:
我需要复制表中包含的所有记录(qa_items_purchases),只提取另一个表中的字段。
编辑:
各表之间的名称有差异,则:

purchase_code AS itempurchase_code
supplier_invoice_code AS item_invoicecodesupplier
supploer_invoice_date as itempurchase_date

最佳答案

试试这个:

INSERT INTO qa_suppliers_invoices (purchase_code,supplier_code, user_code, status_code, supplier_invoice_code,supplier_invoice_date)

SELECT itempurchase_code,supplier_code, user_code, status_code,item_invoicecodesupplier,itempurchase_date FROM qa_items_purchases

关于mysql - MySQL插入循环,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11418833/

10-11 01:27