我想过滤与特定单词或句子匹配的列。例如,如果我选择这个词anti
用于过滤,在以下行中:
this is anti-pattern
antimosquitos products
the word anti is cool
我只想保留最后一个,因为它是唯一一个与整个匹配模式匹配的整体,而不是在另一个单词内。
我尝试过使用RLIKE
我总是得到一个FALSE
值,但我不明白为什么。我期望有一个TRUE
至少在以下 SQL 语句之一中的值:
SELECT RLIKE ('Spray antimosquitos', '\bantimosquitos\b', 'i') as p1;
SELECT RLIKE ('Spray antimosquitos', '\santimosquitos\s', 'i') as p1;
SELECT RLIKE ('Spray antimosquitos', '\santimosquitos', 'i') as p1;
SELECT RLIKE ('Spray antimosquitos', '\santimosquitos', 'i') as p1;
然而,这种情况并非如此。我尝试过其他形式,例如:
SELECT RLIKE ('Spray antimosquitos', '\b antimosquitos \b', 'i') as p1
SELECT RLIKE ('Spray antimosquitos', '*antimosquitos*', 'i') as p1
SELECT RLIKE ('Spray antimosquitos', ' antimosquitos ', 'i') as p1
而且我无法获得返回值 TRUE。
我的 RLIKE 有什么问题吗?