mysql - select rows has numeric length more than x -


i have these values in database under field name : username , table name : users

 ... |  username   | ... --------------------------      |    a651378   |       |     b3789    |       |  c3125621903 |       |    d32168    |       |    e789532   |       | f41589964312 | 

for example how select username has number length greater 6 digits

as above values query should return

... |  username    | ... --------------------------     | c3125621903  |      | f41589964312 | 

assuming not know how long character portions are, can use regular expressions:

select u.* users u u.username regexp '^.*[0-9]{7}.*$'; 

actually, can simplified to:

select u.* users u u.username regexp '[0-9]{7}'; 

when using regular expressions, careful. like patterns match whole string (from beginning end). regexp patterns match within string.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -