I want to query a table with field that contains star (*) character but I could't find a valuable answer. I tried something below
我想查询一个包含星号(*)字符的字段的表,但我找不到有价值的答案。我在下面试了一下
WHERE fieldName regexp '\*'
There are solutions like using 'like' keyword but I wanna know a way that uses 'regexp' keyword.
有一些解决方案,比如使用'like'关键字,但我想知道一种使用'regexp'关键字的方法。
Thanks in advance.
提前致谢。
1 个解决方案
#1
1
You need to escape the backslash one more time since a single backslash inside double or single quotes would be considered as an escape sequence.
您需要再次转义反斜杠,因为双引号或单引号内的单个反斜杠将被视为转义序列。
WHERE fieldName regexp '\\*'
OR
Use character class.
使用字符类。
WHERE fieldName regexp '[*]'
#1
1
You need to escape the backslash one more time since a single backslash inside double or single quotes would be considered as an escape sequence.
您需要再次转义反斜杠,因为双引号或单引号内的单个反斜杠将被视为转义序列。
WHERE fieldName regexp '\\*'
OR
Use character class.
使用字符类。
WHERE fieldName regexp '[*]'