This is a discussion on select query help within the MySQL Database forums, part of the Database Forums category; hi, how would I query my table to return only the records where the field 'mobile' has a valid mobile ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
<me@privacy.net> wrote in message news:uti723-p9v.ln1@mercury.tcm.vispa.net.uk... > hi, > > how would I query my table to return only the records where the field > 'mobile' has a valid mobile telephone number. > > Valid being.. begining 07 and being 11 characters in length. > > many thanks, > > Dave > something like: select mobile from table where mobile like '07%' and length(mobile) = 11; John |
|
|||
|
me@privacy.net wrote:
> hi, > > how would I query my table to return only the records where the field > 'mobile' has a valid mobile telephone number. > > Valid being.. begining 07 and being 11 characters in length. > > many thanks, > > Dave > > You can use a regular expression: select ... WHERE phone_column REGEXP '^07[[:alnum:]]{9}$'; meaning: a string beginning with '07', followed by exactly 9 alphanumeric characters. If they need to be digits, use :digit: instead of :alnum:. References here: http://dev.mysql.com/doc/refman/5.0/en/regexp.html ciao gmax -- _ _ _ _ (_|| | |(_|>< _| http://gmax.oltrelinux.com |
![]() |
| Thread Tools | |
| Display Modes | |
|
|