Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

T-SQL How to escape star (*) character

I want to search about this string

*|*

or more specific

LIKE '%*|*%'

but the

*

means the symbol itself. How to escape it?

EDIT: Actually, I was mislead because of other issue in my code. Anyway, you are completely right that in LIKE statement there is no special meaning for the * character.

like image 629
gotqn Avatar asked Dec 11 '25 14:12

gotqn


1 Answers

You don't need to escape it. * has no special value in a like clause

 select * from yourtable where field LIKE '%*|*%' 

See http://msdn.microsoft.com/en-us/library/ms179859(v=sql.100).aspx

like image 139
podiluska Avatar answered Dec 13 '25 18:12

podiluska



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!