It's been a few years since I did any regex queries, but I swear I used to be able to do something like:

SELECT fieldname FROM tablename WHERE field RLIKE '(^|\|)2(\||$)';

And that would find '2', with an optional '|' at the beginning, or at the beginning of the line, and an optional '|' or end of the line. So, it would match the following:

2|3
1|2|3
1|2

But not

1|20|3

Can someone give me a little guidance on this? I'm pulling my hair out on what should be a simple thing....

The database is currently in 4.1 but will soon be going to 5.0, so, ideally the solution will work in both...

Thanks.

Reply via email to