Reputation: 42753
I have in table column pnum_s
I need get only that rows, which value in column pnum_s
is exactly 10 symbol and all these symbols are only digits
what query must write for this?
I am trying this:
SELECT * FROM mytable WHERE pnum_s REGEXP '^\d+$'
But this not returns 0 rows.
Upvotes: 11
Views: 55815
Reputation: 163
Check out the reference page.
http://dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_regexp
What you're looking for is this:
SELECT * FROM mytable WHERE pnum_s REGEXP '^[[:digit:]]{10}$';
Upvotes: 6
Reputation: 324
I think with Mysql you'll want something like this:
^[[:digit:]]{10}$
Upvotes: 7
Reputation: 29759
The pattern you are looking for is either '^[0-9]{10}$'
or '^[[:digit:]]{10}$'
.
Everything is in the manual.
Upvotes: 24