SQL Question: Finding the literal % in a string

Database

SQL Question: Finding the literal % in a string

I have a column defined as char(60) and I have row values which contain the literal '%' imbedded within the string. I need a where clause which I can pull out only those rows which contain the literal '%'.

ie. Select t1.c2
from t1
where c2 eq 'abc%def'
;
1 REPLY

Re: SQL Question: Finding the literal % in a string

Since % is a wildcard character, you need to use the "escape" clause in the where statement. Something like this, ...

where columnname like '%Q%%' escape 'Q'

in this example, Q is designated as the escape character, but it could be any character (preferably one that is not going to be in the search string). I hope I made that clear, if not, check the Teradata docs.