这是我的SQL查询,它使用join合并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();
}
您可以使用插入选择
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%'
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句