以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 外部查询表转化为集合 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=144096) |
-- 作者:北狐 -- 发布时间:2019/12/10 19:28:00 -- 外部查询表转化为集合 Dim cmd As New SQLCommand Dim ld As DataTable cmd.C cmd.CommandText = "查询 Distinct {销售单}.物料编号 AS 物料编号 From {销售单} " ld = cmd.ExecuteScalar() 如何将外部表查询结果转化为文本集合,结构{"ABZ001","ABZ002","ABZ003","ABZ004","ABZ005"} 可以在另外的内部查询表中使用 “查询 Distinct {销售表}.物料编号 AS 物料编号 From {销售表} where {销售表}.物料编号 in ("& ld &")”
|
-- 作者:有点蓝 -- 发布时间:2019/12/10 20:30:00 -- Dim cmd As New SQLCommand Dim ld As DataTable cmd.C cmd.CommandText = "select Distinct 物料编号 From {销售单} " ld = cmd.ExecuteReader() Dim lst As List(of String) = ld.GetValues("物料编号") dim sql as string = “select Distinct 物料编号 From {销售表} where 物料编号 in (\'" & String.Join("\',\'",l st.ToArray) & "\')” |