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 \"whe
SQLite does not contain regular expression functionality by default.
It defines a REGEXP
operator, but this will fail with an error message unless you or your framework define a user function called regexp()
. How you do this will depend on your platform.
If you have a regexp()
function defined, you can match an arbitrary integer from a comma-separated list like so:
... WHERE your_column REGEXP "\b" || your_integer || "\b";
But really, it looks like you would find things a whole lot easier if you normalised your database structure by replacing those groups within a single column with a separate row for each number in the comma-separated list. Then you could not only use the =
operator instead of a regular expression, but also use more powerful relational tools like joins that SQL provides for you.