SQL LIKE wildcard space character

前端 未结 9 1251
庸人自扰
庸人自扰 2020-12-19 04:28

let\'s say I have a string in which the words are separated by 1 or more spaces and I want to use that string in and SQL LIKE condition. How do I make my SQL and tell it to

9条回答
  •  一整个雨季
    2020-12-19 04:53

    If your dialect allows it, use SIMILAR TO, which allows for more flexible matching, including the normal regular expression quantifiers '?', '*' and '+', with grouping indicated by '()'

    where entry SIMILAR TO 'hello +there'
    

    will match 'hello there' with any number of spaces between the two words.

    I guess in MySQL this is

    where entry RLIKE 'hello +there'
    

提交回复
热议问题