如何在MySQL中代替%匹配一个字符? [英] How to match one character in MySQL in place of %?
本文介绍了如何在MySQL中代替%匹配一个字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以下SQL中:
SELECT * FROM X WHERE Y LIKE "%s";
%
将匹配s
之前的所有字符. %
可以是x
,xx
,xrf
等.
the %
will match any characters before an s
. The %
can be x
, xx
, xrf
, etc.
是否有任何只能匹配一个字符的符号,例如:
Is there any symbol that will only match one character, like:
SELECT * FROM X WHERE Y LIKE "?s"
其中?
仅匹配一个字符,例如a
,b
,c
等?
where ?
will match only one character like a
, b
, c
, etc.?
推荐答案
您要使用下划线(_
)字符.请参阅文档此处.
You want to use an underscore (_
) character. See the documentation here.
这篇关于如何在MySQL中代替%匹配一个字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文