select on field having specific length and starts numeric

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tembil
    New Member
    • Feb 2008
    • 11

    select on field having specific length and starts numeric

    Hi,
    How do I select numeric records from a table in MySQL I need to select ID's the length must be 13 and it must be numeric, I have already selected the length in my where clause and I'm stuck with the numeric records.
    Thanx in advance
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    So?? Show your SQL query and we can see where we can help.

    Ronald

    Comment

    • tembil
      New Member
      • Feb 2008
      • 11

      #3
      Originally posted by ronverdonk
      So?? Show your SQL query and we can see where we can help.

      Ronald
      Hi,
      here my query:[code=mysql]
      select *
      from `tbl_telephone`
      where LENGTH(`RSA ID`) = 13
      and (
      substring(`rsa id`, 1, 1) in ('0', '1', '2','3','4','5' ,'6','7','8','9 ')
      )[/code]
      I need to know if there's another way of doing this
      thanx

      Please enclose any code within the proper code tags. See the Posting Guidelines on how to do that. MODERATOR

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        Using a regular expression makes it a bit shorter:[code=mysql]
        select *
        from `tbl_telephone`
        where LENGTH(`RSA ID`) = 13
        and (substring(`rsa id`, 1, 1) REGEXP '^[0-0]+')[/code]
        Ronald

        Comment

        Working...