这是我使用join在SQL数据库上合并两个表的SQL查询,因此我想将结果发送到新创建的数据库SAP_Mat_StoreBGA_test。
但是,我的查询不起作用,请帮助。
foreach (DataRow row2 in dt1.Rows)
{
query4 = "SELECT * FROM SAP_Mat_StoreBGA BGA LEFT JOIN SAP_Mes_BuildPlan ON SAP_Mes_BuildPlan.SMT_Assembly = BGA.Component WHERE BGA.Component like '73%'"
+ "INSERT INTO SAP_Mat_StoreBGA_test (BGA.Material, BGA.Component, SMT_Assembly) VALUES('" + row2["BGA.Material"]+ "','" + row2["BGA.Component"] + "','" + row2["SMT_Assembly"] + "')";
CheckingCommand.ExecuteNonQuery();
}发布于 2020-03-23 05:06:47
您可以使用插入-选择。
INSERT INTO SAP_Mat_StoreBGA_test (BGA.Material, BGA.Component, SMT_Assembly)
SELECT BGA.Material, BGA.Component, SMT_Assembly FROM SAP_Mat_StoreBGA BGA
LEFT JOIN SAP_Mes_BuildPlan ON SAP_Mes_BuildPlan.SMT_Assembly = BGA.Component
WHERE BGA.Component like '73%'https://stackoverflow.com/questions/60807476
复制相似问题