Split分割提取的元素如何作为SQL搜索条件
Split分割提取的元素如何作为SQL搜索条件?
比如我一张表(表名:key)里某列(列名:searchkey)内容是“abc/d45/frg”
我想把表(表名:news)中存内容的列(列名:list)包含“abc”或“d45”或“frg”的新闻列表显示,我该怎么写这个搜索啊?帮我改改或者帮我把WHERE后面写完整可以吗?
……
rs.open "select searchkey from key where id=1 ",conn,1,1
key=splite(rs(searchkey), "/ ")
……
rs1.open "select * from news where list like …… "
------解决方案--------------------If IsArray(key) then
For i=0 To ubound(key)
if str = " " then
str = "list like '% " & Trim(key(i)) & "% ' "
else
str= str & " or list like '% " & Trim(key(i)) & "% ' "
end if
Next
end if
rs1.open "select * from news where " & str