1

I have a mysql database table with rows like this

id | values

1 | 5,6,8,1,9

2 | 12,22,5,20

3 | 18,55,3,2

I want a help in SELECT statement

To select rows that contain Numbers 1 OR 2

Without selecting rows that contain numbers like 12 or 22

SELECT * FROM test WHERE values REGEXP '/(^[,])?(1)(^[,])?/';
Avinash Raj
  • 172,303
  • 28
  • 230
  • 274

1 Answers1

0

This is the regex you should use: (^|,)[12]($|,)

SELECT * FROM test WHERE values REGEXP '/(^|,)[12]($|,)/';

fennng
  • 1