Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Location
    SW England
    Posts
    102

    Unanswered: Avoid getting same country twice

    I have a DB containing trips around the world.
    I want to create a menu with all the countries we visit but at the moment it returns the whole column. i.e. Brazil 5 times etc.
    How do I avoid repititions?
    I thought I could make an array and check it to see if the country was already there, but I think SQL must have a native routine to achieve the same thing.
    Thanks
    M

  2. #2
    Join Date
    Feb 2004
    Location
    Dublin, Ireland
    Posts
    212
    First of all, you should check your data model and select statement you use to retrieve countries. Probably your SELECT is not defined properly if it returns multiple rows. Anyway, you can retrieve unique names using DISTINCT:
    Code:
    select DISTINCT CountryName
    from ....

  3. #3
    Join Date
    Oct 2005
    Location
    SW England
    Posts
    102
    cool, thanks er.. madafaka.
    my SQL looks like this now, and works a treat:

    "SELECT DISTINCT Country, url_link FROM dest_search ORDER BY country"

    knowing me there's probably still a better way!
    Incidentally the url_link is the path to the detail page and I gather doing it this way allows the search engines to follow the links. at first I put just:
    "SELECT DISTINCT Country FROM dest_search ORDER BY country"
    but that gave me an error because it excluded the url_link data.

    Cheers
    M

Posting Permissions

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