通配符 sql 仅字母字符
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4913964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Wildcard characters sql only alphabet characters
提问by Sudantha
I need to create a rule only for alphabet characters
我只需要为字母字符创建规则
i used the following Wildcard character sequences but didn't work !
我使用了以下通配符序列,但没有用!
LIKE '[A-Za-z]'
LIKE 'a-z'
LIKE 'A-Za-z'
喜欢'[A-Za-z]'
喜欢'az'
喜欢'A-Za-z'
回答by gbn
Double negative like
双重否定喜欢
WHERE
SomeCol NOT LIKE '%[^a-z]%'
Ignoring the first NOT, this means "match any character notin the range a to z".
忽略第一个 NOT,这意味着“匹配不在a 到 z 范围内的任何字符”。
Then, you reverse using the first NOT which means "don't match any character notin the range a to z"
然后,您使用第一个 NOT 反转,这意味着“不匹配不在a 到 z 范围内的任何字符”
Edit, after comment
编辑,评论后
LIKE '%[a-z]%'
means "find any single character between a-z. So 111s222
is matched for example because s
matches in this like.
LIKE '%[a-z]%'
意思是“在 az 之间找到任何单个字符。所以111s222
匹配,例如因为s
匹配在这个喜欢。