Vivek Rana
Vivek Rana

Reputation: 1

Using wildcards

Can anyone help me out with this-

There is a column in the database as "TEXT". This column hold some string value. I want to search any row that is having '%' in this column .

For eg how will i search for a row having value 'Vivek%123' in the column TEXT

Upvotes: 0

Views: 936

Answers (2)

Jeremy C.
Jeremy C.

Reputation: 2465

In sql there is something known as an escape character, basically if you use this character it will be ignored and the character right behind it will be used as a literal instead of a wildcard in the case of %

WHERE Text LIKE '%!%%'
ESCAPE '!' 

The above sql statement will allow you to search for any string containing a percentage character '%' so it could find anything in the format of

string%string

Upvotes: 1

Iswanto San
Iswanto San

Reputation: 18569

You must escape the % character

WHERE COL1 LIKE 'Vivek@%123' ESCAPE '@' ;

Upvotes: 1

Related Questions