[英]Search Table For Whole Word In Another Table, If Found Exclude From Result
Using MS Access, how would I create a query using SQL to search a table containing search terms (1 to 10 word phrases) for keywords or keyword phrases in another table, then exclude any matches to produce a list of search terms that did not match? 使用MS Access,我将如何使用SQL创建查询来搜索包含搜索词(1到10个单词短语)的表中的另一个表中的关键字或关键词短语,然后排除任何匹配项以生成不匹配的搜索词列表?
NOTE: The Negative keywords include 'sign' and 'attach' but this should not prevent 'tree house design' and 'attachment point' from showing up in the result set. 注意:否定关键字包括'sign'和'attach',但这不应阻止'tree house design'和'attachment point'在结果集中显示。 I am using Access 2007.
我正在使用Access 2007。
here's the query 这是查询
SELECT SearchTerms.Phrase
FROM SearchTerms, Negatives
GROUP BY SearchTerms.Phrase
HAVING (((Max(InStr(" " & [phrase] & " "," " & [exclude] & " ")))=0));
Where SearchTerms is a table of the search terms and Phrase is the search term field, Negatives is the table with negative terms to exclude and Exclude is the field name in that table. 其中SearchTerms是搜索词的表,而Phrase是搜索词的字段,Negatives是要排除的负词的表,Exclude是该表中的字段名。
The trick is that I added spaces before & after the phrase, then looked for matches with the words to exclude and leading/trailing blanks. 诀窍是,我在词组的前后添加空格,然后寻找与要排除的词和前导/尾随空格的匹配项。 This way I can identify only the phrases that match whole words and not parts of words.
这样,我只能识别与整个单词匹配的短语,而不能识别单词的一部分。
Worked fine when I set up the tables & tested it. 当我设置表格并对其进行测试时,工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.