Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    39

    Unanswered: Check if part of a field is numeric.

    Hi all,

    I want to check if part of a field is numeric. For example, I have a field containing values such as

    Anne
    Anne-France
    Annemary
    Anne123

    I want to find Anne123 by checking if the contents of the field past 'Anne' is numeric.

  2. #2
    Join Date
    Sep 2003
    Posts
    39
    I currently have:

    SELECT
    max(username) as lastUsername
    FROM
    tbUser usr
    WHERE
    left(usr.username, len(username)) = username
    and format(right(usr,username, char_length(usr.username) - len(username)) = cast(right(usr,username, char_length(usr.username) - len(username)) as unsigned)

    where the italic text is simply a variable filled in with PHP.

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    ... where username regexp "^Anne[[:digit:]]+"

    or something like that
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •