以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请问,菜单里的查询重复项,指的是针对单列,如果针对双列甚至更多列,有快速的命令吗?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=61292)

--  作者:Bin
--  发布时间:2014/12/10 14:36:00
--  
select 第一列,第二列 from {表A} group by 第一列,第二列 having(count(*))>1

查找第一列第二列重复

--  作者:有点甜
--  发布时间:2014/12/10 15:13:00
--  

 汗,原来这么麻烦。下面代码是取出不重复的数据的。

 

Dim str As String = "第一列,第二列"
Dim idx As String = ""
Dim ary() As String = str.Split(",")
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
For Each dr As DataRow In DataTables("表A").Select("第一列 is not null", str)
    Dim flag As Boolean = False
    For Each a As String In ary
        If pdr IsNot Nothing AndAlso dr(a) <> pdr(a) Then
            flag = True
        End If
    Next
    If flag = False Then
        count += 1
    Else
        If count = 1 Then
            idx &= pdr("_Identify") & ","
        End If
        count = 1
    End If
    pdr = dr
Next

For Each a As String In ary
    If pdr IsNot Nothing AndAlso Tables("表A").Rows(Tables("表A").Rows.count-2)(a) <> pdr(a) Then
        idx &= pdr("_Identify") & ","
    End If
Next

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


--  作者:有点甜
--  发布时间:2015/1/20 21:10:00
--  

看你原帖,或者看下面代码

 

Dim str As String = "第一列,第二列"
Dim idx As String = ""
Dim ary() As String = str.Split(",")
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
For Each dr As DataRow In DataTables("表A").Select("第一列 is not null", str)
    Dim flag As Boolean = False
    For Each a As String In ary
        If pdr IsNot Nothing AndAlso dr(a) <> pdr(a) Then
            flag = True
        End If
    Next
    If flag = False Then
        count += 1
    Else
        If count = 1 Then
            idx &= pdr("_Identify") & ","
        End If
        count = 1
    End If
    pdr = dr
Next

For Each a As String In ary
    If pdr IsNot Nothing AndAlso Tables("表A").Rows(Tables("表A").Rows.count-2)(a) <> pdr(a) Then
        idx &= pdr("_Identify") & ","
    End If
Next

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


--  作者:有点甜
--  发布时间:2015/1/20 21:35:00
--  
以下是引用mojunming在2015-1-20 21:25:00的发言:

需要同时取出哪些重复记录?编码应该如何修改?

 

什么意思?6楼取出的就是重复的数据啊


--  作者:有点甜
--  发布时间:2015/1/20 21:42:00
--  

 这段不能去掉

 

For Each a As String In ary
    If pdr IsNot Nothing AndAlso Tables("I0_Joint").Rows(Tables("I0_Joint").Rows.count-2)(a) <> pdr(a) Then
        idx &= pdr("JointID") & ","
    End If
Next


--  作者:有点甜
--  发布时间:2015/1/21 9:59:00
--  

 1、Filter,是针对已经加载的数据的。

 

 2、如果要针对没加载的数据,需要重新加载数据

 

DataTables("表A").LoadFilter = "_Identify not in (" & idx.trim(",") & ")"

DataTables("表A").Load


--  作者:有点甜
--  发布时间:2015/1/21 10:06:00
--  

 看12楼

 

 同时,如果这种,建议你用sql语句直接重修加载数据啊。

 

 参考

 

http://www.cr173.com/html/7529_1.html

 

http://www.foxtable.com/help/topics/2721.htm

 


--  作者:有点甜
--  发布时间:2015/1/21 14:38:00
--  
以下是引用mojunming在2015-1-21 14:37:00的发言:

查找两列重复项用SQL语言怎么编,才好?

 

两列合并成一列,比如

 

 s elect 第一列 + \'分隔符|\' + 第二列 as 组合列 From {表A}