vbaado执⾏多条mysql语句_access按钮多条sql语句VBA 然后你就可以写你要执⾏的⼀系列代码了,我的⽐较简单,有⽐较复杂的请⾃⾏百度
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 <>
access转mysql教程视频
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

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。