regexsqlitequery-string

How do I use regex in a SQLite query?


I'd like to use a regular expression in sqlite, but I don't know how.

My table has got a column with strings like this: "3,12,13,14,19,28,32" Now if I type "where x LIKE '3'" I also get the rows which contain values like 13 or 32, but I'd like to get only the rows which have exactly the value 3 in that string.

Does anyone know how to solve this?


Solution

  • SQLite3 supports the REGEXP operator:

    WHERE x REGEXP <regex>