以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于 IN  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=178422)

--  作者:czy66ds
--  发布时间:2022/7/4 9:28:00
--  关于 IN
dim str as string = (\'D002\',\'D008\',\'D045\',\'D055\')
执行sql:Sel ect * from {库存记录表} where 编码 In  (\'D002\',\'D008\',\'D045\',\'D055\') 可以得到预想的结果

我的问题是:
在Sele ct * from {库存记录表} where 编码 In 后使用变量str该如何写?
在Sele ct * from {库存记录表} where 编码 In str?

--  作者:有点蓝
--  发布时间:2022/7/4 9:57:00
--  
dim str as string = "(\'D002\',\'D008\',\'D045\',\'D055\')"

dim sql as string = "Select * from {库存记录表} where 编码 In " & str  & ""
msgbox(sql)

--  作者:czy66ds
--  发布时间:2022/7/4 10:32:00
--  
图片点击可在新窗口打开查看
我是在这里执行代码

--  作者:有点蓝
--  发布时间:2022/7/4 10:55:00
--  
命令窗口里才能使用变量