且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

SQL从不同数据库中的多个表插入数据

更新时间:2023-11-30 21:28:34

我认为您需要为此使用JOIN:

I think you need to look into using a JOIN for this:

INSERT INTO a1.cat (id, img)
SELECT p.id, pi.name
FROM topshop_test.product p 
    JOIN topshop_test.product-images pi ON p.id = pi.productid

这假定product-images表具有一个productid字段,该字段链接到product表.

This assumes the product-images table has a productid field that links to the product table.