以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  多值字段的模糊查询  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=130883)

--  作者:gudao123456
--  发布时间:2019/2/10 12:39:00
--  多值字段的模糊查询
老师新年好!对于多值字段的查询,如何通过代码设置含某个值的查询,比如字段A的中含有XXX,YYY,ZZZ中的部分或全部,如何将其中含有YYY的行选出来。谢谢

[此贴子已经被作者于2019/2/10 12:41:39编辑过]

--  作者:有点甜
--  发布时间:2019/2/10 13:46:00
--  
Tables("表A").filter = "第一列 like \'%YYY%\'"
--  作者:gudao123456
--  发布时间:2019/2/10 22:24:00
--  
谢谢!
下面问题代码的问题在哪里,提示了Like前 缺少运算符,应该如何改才正确?
Dim Cols1() As String = {"xm","sfzhm","xb","mz","xh","nj","bj","xq","zxzt","xx","xslx","zmcl","lrr","lrsj"}
Dim Cols2() As String ={"xm","sfzhm","xb","mz","xh","nj","bj","xq","zxzt","xx","xslx","zmcl","lrr","lrsj"}
Dim fil As String="like \'%YYY%\'  And sfytjmxzf=\'False\'"
For Each dr1 As DataRow In DataTables("xszxztb").Select("xsxm"=fil) 
 Dim dr2 As DataRow = DataTables("mxzfb").AddNew()
 For i As Integer = 0 To Cols1.Length -1
 dr2(Cols2(i)) = dr1(Cols1(i))
 Next
dr1("sfytjmxzf")=True
Next
其中:xsxm 为表xsxztb的一个多值字段
改成:Dim fil As String="like %YYY%  And sfytjmxzf=\'False\'"
For Each dr1 As DataRow In DataTables("xszxztb").Select(xsxm=fil) 
...
后又提示 xsxm没有定义,如果把xsxm 改成:“xsxm”,不提示错误,但没有把符合条件的记录添加到目标表

谢谢!

[此贴子已经被作者于2019/2/10 22:41:27编辑过]

--  作者:有点甜
--  发布时间:2019/2/11 9:28:00
--  
Dim Cols1() As String = {"xm","sfzhm","xb","mz","xh","nj","bj","xq","zxzt","xx","xslx","zmcl","lrr","lrsj"}
Dim Cols2() As String ={"xm","sfzhm","xb","mz","xh","nj","bj","xq","zxzt","xx","xslx","zmcl","lrr","lrsj"}
Dim fil As String=" xsxm like \'%YYY%\'  And sfytjmxzf=\'False\'"
For Each dr1 As DataRow In DataTables("xszxztb").Select(fil)
    Dim dr2 As DataRow = DataTables("mxzfb").AddNew()
    For i As Integer = 0 To Cols1.Length -1
        dr2(Cols2(i)) = dr1(Cols1(i))
    Next
    dr1("sfytjmxzf")=True
Next

--  作者:gudao123456
--  发布时间:2019/2/11 23:55:00
--  
谢谢!我执行后虽然没有提示错误,但仍然还是没有把符合条件的拷贝到目标数据表。我再检查一下看看是否有其他问题
--  作者:有点甜
--  发布时间:2019/2/12 9:03:00
--  

那你执行这个代码,看筛选到什么数据

 

Tables("xszxztb").filter = "xsxm like \'%YYY%\'  And sfytjmxzf=False"

 


--  作者:gudao123456
--  发布时间:2019/2/12 17:35:00
--  
执行上述代码,可以筛查出符合条件的行。谢谢!
--  作者:有点甜
--  发布时间:2019/2/12 17:58:00
--  
以下是引用gudao123456在2019/2/12 17:35:00的发言:
执行上述代码,可以筛查出符合条件的行。谢谢!

 

那这个代码,不应该有问题 For Each dr1 As DataRow In DataTables("xszxztb").Select(fil)


--  作者:gudao123456
--  发布时间:2019/2/12 21:23:00
--  
可以了,谢谢!
问题出在Dim fil As String=" xsxm like \'%YYY%\'  And sfytjmxzf=\'False\'" 中" xsxm like ..."前面多了个空格(我理解不应该影响啊)