[英]MS Access 2013 SQL wildcarding, regex-like syntax
The link below seems to indicate that "[a-zA-Z]*" should only match on zero or more alphabetic characters.下面的链接似乎表明“[a-zA-Z]*”应该只匹配零个或多个字母字符。
https://msdn.microsoft.com/EN-US/library/office/ff192499.aspx https://msdn.microsoft.com/EN-US/library/office/ff192499.aspx
However, in testing it seems to return results that I don't expect;然而,在测试中它似乎返回了我不期望的结果; for example, that contain spaces.
例如,包含空格。
Select * from table1 where name like 'r[a-zA-Z]* e[a-zA-Z]*'
Should only return consecutive words in the name field where the first word starts with r and none or more alphabetic chars separated by a space and a second word that starts with e.应该只返回 name 字段中的连续单词,其中第一个单词以 r 开头,没有或多个字母字符由空格分隔,第二个单词以 e 开头。
But executing this statement returns the following (some examples from the result set)但是执行此语句返回以下内容(结果集中的一些示例)
Is there a way to get the search to return exactly what I expect?有没有办法让搜索完全返回我的期望? What am I not understanding?
我不明白什么?
It is not a regular expression.它不是正则表达式。 The
*
does not apply to the [a-zA-Z]
. *
不适用于[a-zA-Z]
。
r[a-zA-Z]* e[a-zA-Z]*
is interpreted as: r[a-zA-Z]* e[a-zA-Z]*
被解释为:
r
e
e
Unfortunately you have to use something like this:不幸的是,你必须使用这样的东西:
Select * from table1 where name like "r*" and mid(name , instr(name , " ") + 1, 1) = "e"
which isn't pretty and isn't precisely what you want.这不漂亮,也不是你想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.