This question already has answers here:
How can I escape square brackets in a LIKE clause? (10 answers)
Closed 4 days ago.
select *
from Table1
where Email = 'test()<>[]:;@\\@test.com'
select *
from Table1
where Email like '%test()<>[]:;@\\@test.com%'
The first query is returning data, while the second query is not. How can we use like
in this query?
The second query should return the same data as the first.
1条答案
按热度按时间u2nhd7ah1#
As @siggemannen has rightly pointed out : (I will use his original sentence from above comment):
[] is part of the LIKE pattern matching . which matches empty set of characters. To be able to use such characters, you have to ESCAPE them with a escape clause.
So, Your query can be written as :
Here is a demo using dbfiddle