Hello I have the records and want to select those records only which starts with 01,03 and of the string length greater than 4.How can it be done using REGEXP in MySQL. 0112345 0312345 01123 03123 0156 0356 00789001 1234567 0112345 00112345 0312345 345667
Appreciate for the help.
Thanks
You don`t need RegEx for this one. Try this: SELECT foo FROM table WHERE foo (LIKE '01%' OR LIKE '03%') AND length(foo) >4
Just a little correction to malariajoes query:
SELECT foo FROM table WHERE (foo LIKE '01%' OR foo LIKE '03%') AND CHAR_LENGTH(foo) >4
Well, if you really want the regular expression way (even though the above works I'm sure)...
you could do a
SELECT foo FROM table WHERE (foo REGEXP '^0[13][0-9]{2,}$')
That's great ... above two codes works perfectly.