A single character can be escaped like this:
select * from tableName where columnName like 'CU_C' escape '_';
I need to escape multiple characters ("% " and "_"):
select * from tableName where columnName like 'C%U_C' escape ??;
How do I escape multiple characters?
You misunderstood the meaning of escape
: it lets you define a character such that when you put it in front of another character, that other character is interpreted literally, not as a meta-character. You need only one such escape character: you can use it to escape any meta-character.
In the example below I used '#'
as my escape character:
select * from tableName where columnName like 'C#%U#_C' escape '#'
This tries to match C%U_C
strings where both '%'
and '_'
are interpreted literally, not as a sequence of any characters or any single character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With