This question also has the answer , but it mentions DB2 specifically.
How do I search for a string using LIKE
that already has a percent %
symbol in it? The LIKE
operator uses %
symbols to signify wildcards.
This question also has the answer , but it mentions DB2 specifically.
How do I search for a string using LIKE
that already has a percent %
symbol in it? The LIKE
operator uses %
symbols to signify wildcards.
5条答案
按热度按时间dhxwm5r41#
Use brackets. So to look for 75%
This is simpler than ESCAPE and common to most RDBMSes.
weylhg0b2#
You can use the
ESCAPE
keyword withLIKE
. Simply prepend the desired character (e.g. '!') to each of the existing%
signs in the string and then addESCAPE '!'
(or your character of choice) to the end of the query.For example:
This will make the database treat 80% as an actual part of the string to search for and not 80(wildcard).
Documentation on
LIKE
p5fdfcr13#
ztyzrc3y4#
You can use the code below to find a specific value.
When you want a single digit number after the% sign, you can write the following code.
vxbzzdmp5#
In MySQL,
WHERE column_name LIKE '%|%%' ESCAPE '|'