How to escape wildcard characters in “like” clause?

后端 未结 1 1956
悲哀的现实
悲哀的现实 2021-01-11 21:14

How can I escape the wildcard characters in a like clause?

E.g.:

select foo from Foo as foo where foo.bar like \'%\' || :filter ||\'%\'
quer         


        
相关标签:
1条回答
  • 2021-01-11 21:41

    In Hibernate 3 you can use the escape parameter to specify the escape char:

    select foo from Foo as foo where foo.bar like '!%' escape '!'
    

    I think that should work, although I have never tried it in practice.

    0 讨论(0)
提交回复
热议问题