Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display numbers which are like 11111 or similar in MS sql

I am trying to display numbers from ID column which should have the same number.

Like 11111 or 2222 or 33333

select * from table where id like '1111' - this will give me 1 value, but there are many values like 1111111111 or 111111 which I am not sure of, as there are more than 100k records.

like image 452
rookie Avatar asked Sep 21 '25 05:09

rookie


1 Answers

Using regular expressions

SELECT * from table where id REGEXP '^(1+|2+|3+|4+|5+|6+|7+|8+|9+)$';
like image 78
gray Avatar answered Sep 22 '25 20:09

gray