Tenebris Tenebris - 6 months ago 12
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

You should escape the character [ and ]

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