Foxtable(狐表)用户栏目专家坐堂 → [求助]查询时distinct的问题


  共有1893人关注过本帖树形打印复制链接

主题:[求助]查询时distinct的问题

帅哥哟,离线,有人找我吗?
katent
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:9 积分:177 威望:0 精华:0 注册:2017/3/10 16:51:00
[求助]查询时distinct的问题  发帖心情 Post By:2017/5/7 13:24:00 [只看该作者]

是这样的,
我创建了一个查询表查询A,B,C字段,根据A不同B,C可以有相同的重复值,比如:
A  B  C
1  2  3
2  2  3
3  2  3

在窗口中只显示B,C字段,但可以用A字段去like查询,
这时我怎么能保证B,C不显示重复数据?

窗口的Table控件好像没有distnict属性

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/5/7 16:19:00 [只看该作者]

 把重复的剔除

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列,第三列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"


 回到顶部