Tenebris Tenebris - 1 year ago 56
SQL Question

Trying to find a string with RLIKE that contains [text]

Hi I am trying to find all strings in my database that have a format as folowed
sometext [sometext] sometext. I tried to do it like this:

SELECT AlbumName
FROM album
WHERE AlbumName RLIKE '.*[.*].*';


The problem I think I have that
RLIKE
takes
[.*] as [a-z]
and I get back everything.

Answer Source

You should escape the character [ and ]

SELECT AlbumName
FROM album
WHERE AlbumName RLIKE '.*\\[.*\\].*';