以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]查询中in的用法 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=149407) |
-- 作者:wangnovel -- 发布时间:2020/4/30 15:59:00 -- [求助]查询中in的用法 有表名为erid,erid表中有个字段errorid,该字段为integer型 另外有表tbl,tbl有个字段id(integer型)。现在,需要筛选tbl中的行,筛选条件是:id等于erid中的值。 我写的代码是: Dim ider As List (of Integer) dim dr as datarow For Each dr In DataTables("erId").Select("") ider.Add(dr("errorid")) Next Tables("tbl").Filter = "Id in ( ider) " 请问,我的代码错在哪里? |
-- 作者:狐狸爸爸 -- 发布时间:2020/4/30 17:25:00 -- 可以看看: 如果是字符型: Dim ider As String dim dr as datarow For Each dr In DataTables("erId").Select("") Ider = Ider & ",\'" & dr("errorid") & "\'" Next Tables("tbl").Filter = "Id in (” & ider.Trim(",") & ") " 如果是整数: Dim ider As String dim dr as datarow For Each dr In DataTables("erId").Select("") Ider = Ider & "," & dr("errorid") Next Tables("tbl").Filter = "Id in (” & ider & ") " |