How to search for all % in a column

Analytics
Enthusiast

How to search for all % in a column

SELECT v_high, v_low, INDEX(first_hit_referrer,'%') AS location, SUBSTRING(first_hit_referrer FROM INDEX(first_hit_referrer,'%') FOR 3) AS val, first_hit_referrer

FROM tbl1

WHERE FIRST_HIT_REFERRER LIKE '%"%"%'

The above does not give me the results I need.

1 REPLY
Teradata Employee

Re: How to search for all % in a column

Not clear exactly what you intend, but perhaps this will help. Since '%' and '_' have special meaning in a LIKE clause, if you want to match those characters you must define and use an ESCAPE character, e.g.

... LIKE '%\%%' ESCAPE '\'
Matches if the field contains at least one % character somewhere