【发布时间】:2023-03-21 12:05:01
【问题描述】:
如何将两个 SQl 查询合并为一个
在我的例子中是 3 个表名
Remain_cotton,add_cotton,Sell_Table
conn.Execute _
"INSERT INTO Remain_Cotton(No_Of_Bottle) " & _
"SELECT sum(No_Of_Bottle)" & _
"FROM add_cotton Where Cateogry='Large'"
conn.Execute _
"INSERT INTO Remain_Cotton(Quantity) " & _
"SELECT sum(Quantity)" & _
"FROM Sell_Detail Where Cateogry='Large'"
我想要什么
conn.Execute _
"INSERT INTO Remain_Cotton(No_Of_Bottle)(Quantity) " & _
"SELECT sum(No_OF_Bottle),sum(Quantity)" & _
"FROM add_cotton,Sell_Detail Where Cateogry='Large'"
我之前问过类似的问题,但它是一个SQL语句,所以请不要将它与上一个连接起来
【问题讨论】:
-
如果您发布您的实际代码、相关的数据库架构和您看到的错误消息会有所帮助
-
**Dim large_tbl As String Dim sell_large As String **large_tbl = "SELECT Sum(No_Of_Bottle) FROM add_cotton where Cateogry='Large'" sell_large = "SELECT Sum(Quantity) FROM Sell_Detail where Cateogry= '大'"
-
如果你编辑你的问题会更好(这次是为你做的) - 你仍然没有显示任何运行查询的代码或任何试图处理结果的代码,你没有解释什么您看到的错误/结果
-
非常感谢我编辑了它等等
-
@Deanna 对不起??请您详细说明一下....