I am trying to match in sql using the following:
SELECT * FROM mytable WHERE vendor_id REGEXP '^0\d+'
However, it returns no results. Doing vendor_id REGEX '^0'
works though. How do I search for 0 followed by other digits?
I am trying to match in sql using the following:
SELECT * FROM mytable WHERE vendor_id REGEXP '^0\d+'
However, it returns no results. Doing vendor_id REGEX '^0'
works though. How do I search for 0 followed by other digits?
MySQL regex uses POSIX Extended Regular Expression (ERE) that doesn't know about PCRE regex property classes such as \d
, \w
etc. You can use [0-9]
or POSIX class [[:digit:]]
as:
SELECT * FROM mytable WHERE vendor_id REGEXP '^0[0-9]+'
OR else:
SELECT * FROM mytable WHERE vendor_id REGEXP '^0[[:digit:]]+'