Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql MS Access变量字符串搜索_Sql_Ms Access - Fatal编程技术网

Sql MS Access变量字符串搜索

Sql MS Access变量字符串搜索,sql,ms-access,Sql,Ms Access,我想创建一个查询,用于标识长文本字符串不包含任何子字符串列表的条目 我所拥有的是 SELECT [other necessary data], [Long text string] WHERE [Long String] NOT LIKE "*[substring1]*" AND [Long string] NOT LIKE "*[substring2]*" AND [Long string] NOT LIKE "*[substring3]*" 这个很好用。然而!我希望排除的子字符

我想创建一个查询,用于标识长文本字符串不包含任何子字符串列表的条目

我所拥有的是

SELECT [other necessary data], [Long text string]
WHERE [Long String] NOT LIKE "*[substring1]*" 
  AND [Long string] NOT LIKE "*[substring2]*" 
  AND [Long string] NOT LIKE "*[substring3]*"
这个很好用。然而!我希望排除的子字符串列表是可变的,例如,项目1排除子字符串1和3,项目2排除子字符串2、3和17,等等


关于如何做这件事有什么建议吗?

也许是这样的事情?然后,您只需调用它,最多可以排除四个字符串,并将sql用于您希望执行的任何操作

Function strsql(ex1 as string,Optional ex2 as string = "", _  
Optional ex3 as string = "", Optional ex4 as string = "") as string
strsql = "SELECT [other necessary data], [Long text string] _  
WHERE [Long String] NOT LIKE " & chr(34) & "*" & ex1 & "*" & _  
chr(34)
If ex2 <> "" then  
strsql = strsql & " AND [Long String] NOT LIKE " & chr(34) & _  
"*" & ex2 & "*" & chr(34)  
End if  
If ex3 <> "" then  
strsql = strsql & " AND [Long String] NOT LIKE " & chr(34) & _  
"*" & ex3 & "*" & chr(34)  
End if  
If ex4 <> "" then  
strsql = strsql & " AND [Long String] NOT LIKE " & chr(34) & _  
"*" & ex4 & "*" & chr(34)  
End if
strsql = strsql & ";"  
End Function
函数strsql(ex1作为字符串,可选ex2作为字符串=”,\u
可选ex3作为字符串=”,可选ex4作为字符串=”)作为字符串
strsql=“选择[其他必要数据],[长文本字符串]\u
其中[长字符串]不象“&chr(34)&”*”&ex1&“*”&\u
人权专员(34)
如果ex2“那么
strsql=strsql&“和[Long String]不一样”&chr(34)&\u
*”&ex2&“*”&chr(34)
如果结束
如果ex3“那么
strsql=strsql&“和[Long String]不一样”&chr(34)&\u
*”&ex3&“*”&chr(34)
如果结束
如果ex4“那么
strsql=strsql&“和[Long String]不一样”&chr(34)&\u
*”&ex4&“*”&chr(34)
如果结束
strsql=strsql&“;”
端函数

请演示您是如何尝试解决问题的,以及您的错误所在。请参见如何提问您要从中选择的表中是否有一列?