vba ado 执行多条mysql 语句_access 按钮 多条sql语句 VBA
发布日期:2021-06-24 11:23:47 浏览次数:3 分类:技术文章

本文共 1104 字,大约阅读时间需要 3 分钟。

然后你就可以写你要执行的一系列代码了,我的比较简单,有比较复杂的请自行百度

Private Sub Command0_Click()

str1 = "create table result(NewID char(255),DoAdmit Date,DoDischarge Date,Interval long)"

str2 = "insert into result(NewID,DoAdmit)select distinct NewID,(select max(DoAdmit) from 2002table b where b.NewID = a.NewID) as DoAdmit  from ( select NewID from 2002table group by NewID having count(NewID)>1) a"

str3 = "select NewID,(select max(DoDischarge) from 2002table a where a.NewID = r.NewID And a.DoAdmit = r.DoAdmit) as DoDischarge into t from result r"

str4 = "select b.NewID, (select top 1 DoDischarge from 2002table a where a.NewID = b.NewID And a.DoDischarge <> b.DoDischarge order by DoDischarge desc) as DoDischarge into t1 from t b "

str5 = "UPDATE result  a,t1 b Set a.DoDischarge = b.DoDischarge WHERE a.NewID = b.NewID"

str6 = "update result set interval=doadmit-dodischarge"

str7 = "drop table t"

str8 = "drop table t1"

CurrentDb.Execute (str1)

CurrentDb.Execute (str2)

CurrentDb.Execute (str3)

CurrentDb.Execute (str4)

CurrentDb.Execute (str5)

CurrentDb.Execute (str6)

CurrentDb.Execute (str7)

CurrentDb.Execute (str8)

End Sub

转载地址:https://blog.csdn.net/weixin_32473663/article/details/114008532 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:弹性方法计算连续梁板内力_(梁板结构)混凝土结构设计复习题及答案
下一篇:python怎么创建字符串列表_如何在python列表中为每个字符串创建子列表?

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月25日 23时49分10秒