Mazhar Ahmed Mazhar Ahmed - 4 months ago 8
MySQL Question

How to match one character in MySQL in place of %?

In the following SQL:

select * from X where Y like "%s";


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"


where
?
will match only one character like 'a', 'b', 'c', etc.?

Answer

You want to use an underscore (_) character. See the documentation here.

Comments