3

I have a column participants which contains a value like "99005|99001|99002|99001999|99004" which are user logins.

What exactly I want is to match "99001" without matching "99001999".

Here is my method:

SELECT * FROM `bv_sklad_products` WHERE `stage`=4 AND `participants` REGEXP ('^([^\|]+(\|))*(99001|99005)((\|)[^\|]+)*$') AND `start_date` BETWEEN '2015-07-09' AND '2015-07-10' ORDER BY `id` DESC LIMIT 0,100

And the error message I get:

Got error 'empty (sub)expression' from regexp

What am I doing wrong?

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
BorissOliSiin
  • 317
  • 1
  • 5
  • 13

1 Answers1

6

You may use word boundaries.

regexp  '[[:<:]]99001[[:>:]]'

or

regexp '(^|[|])99001([|]|$)'
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274