If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Avoid getting same country twice

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-06-05, 12:51
darkmunk darkmunk is offline
Registered User
 
Join Date: Oct 2005
Location: SW England
Posts: 102
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
Reply With Quote
  #2 (permalink)  
Old 11-06-05, 13:29
madafaka madafaka is offline
Registered User
 
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 ....
Reply With Quote
  #3 (permalink)  
Old 11-06-05, 14:43
darkmunk darkmunk is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On