SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: MySQL Help

  1. #1
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL Help

    Is there a way to search for records where a fields starts with either a number or symbols such as !,@,#,$,%,&,* ?
    SK

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    select yourfield
    from yourtable
    where yourfield regexp "[^[:alpha:]]"

    or something like that, check REGEXP in the manual
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well this is the code i have so far for the numbers, can't figure out how to get symbols to work with this though:

    SELECT field FROM table WHERE LEFT(field, 1) BETWEEN '0' AND '9'
    SK

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    well, if you don't want to look up REGEXP, you could try
    Code:
    where not (lcase(left(field, 1)) between 'a' and 'z')
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No one said I wasn't going to look . I will soon. Thanks.
    SK

  6. #6
    SitePoint Guru SharifTK's Avatar
    Join Date
    Jan 2004
    Location
    New York, NY
    Posts
    621
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok I am trying to figure it out:

    SELECT field FROM table WHERE field = REGEXP [[:alnum:]]+

    or

    SELECT field FROM table WHERE REGEXP '^!@#$%^&*()1234567890'

    SK


Bookmarks

Posting Permissions

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