Basically I have below query.
Select * from testtabel
where call_id like '%7534567'
or call_id like '%7134576' or ..... ;
7534567,7134576 are not any pattern. So I need to check any call_id which ends 7534567 or 7134576. since I have many to check without using LIKE can I use regexp to check that?
refered Using multiple values in mySQL regexp and
I tried as below,
Select * from testtabel where call_id REGEXP '^(7534567|7134576)$';
But this provides zero records. Can someone show me how should I do that?
2
Answers
Did you try like this to match multiple patterns using
REGEXP
?The
^
anchor matches (here, requires the match at) the start of the string.You need to use
Details:
([^0-9]|^)
– any non-digit char or start of string(7534567|7134576)
–7534567
or7134576
char sequence$
– end of string.See the regex demo.