SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,048
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL search domains by tld

    Hi Guys!

    I have a MySQL database that contains domain names and I need to search them by extension (i.e .com, .co.uk, .org etc..).

    Domains are stored in the database in this format:

    mydomain.com
    mytest.org

    Let's say I wanted to search the above records and return all rows with .com?

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    WHERE domain LIKE '%.com'

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    store two columns for the domain -- the domain itself and the tld -- and put an index on bofadem

    then your search will be efficient --
    Code:
    WHERE tld = 'co.uk'
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •