SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MS SQL: Search for certain characters

    hello,
    how do i search for certain characters after a certain character in my db. e.g

    If i want to search for all emails that full under a certain domain e.g.

    search for all characters after the '@' sign to pick the domain

    e.g Get all email that full under a certain domain e.g. yahoo.com

    how do i achieve this ?

    Afrika

  2. #2
    S1tepoint Surfer drochili's Avatar
    Join Date
    Aug 2002
    Location
    Mississauga, Canada
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's 2 ways that come to mind:
    - Use the 'LIKE' clause (don't remember syntax, but should be something like SELECT email FROM tblEmails WHERE email LIKE %@yahoo.com) ... you can use wildcards in there. Just lookup the syntax on MS's web
    - If you know the domain... SELECT email FROM tblEmails WHERE RIGHT(email , 9) = '@yahoo.com')

  3. #3
    Afrika
    Join Date
    Jul 2004
    Location
    Nigeria
    Posts
    1,737
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot drochili

    its funny how easily we forget

    i used the wildcard % and it does just what i want.
    SELECT * FROM users WHERE email LIKE '%yahoo.com'
    have a nice day

  4. #4
    S1tepoint Surfer drochili's Avatar
    Join Date
    Aug 2002
    Location
    Mississauga, Canada
    Posts
    466
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad to be of help


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
  •