How to query star (*) character in a field in where clause for mysql

1.2k Views Asked by At

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.

Thanks in advance.

1

There are 1 best solutions below

0
On

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 '[*]'