Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 01-30-2005, 10:40 PM   PM User | #1
dswimboy
Regular Coder

 
dswimboy's Avatar
 
Join Date: Nov 2003
Location: mostly in Ann Arbor
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
dswimboy is an unknown quantity at this point
return only distinct matches

I have a table with three Keys. riverID (Primary), river name, and state. I want to list all the states that have rivers in them. the following query returns states multiple times, becuase there are multiple rivers in each state.
Code:
SELECT `state`
FROM `rivers`
What do I do to return the states that have rivers in them ony once?

If you don't understand my question, please ask for an example. If you do understand my question and know I'm not describing properly, please help me describe it.
__________________
"There is more than one way to do it."
dswimboy is offline   Reply With Quote
Old 01-30-2005, 10:49 PM   PM User | #2
Sayonara
Regular Coder

 
Sayonara's Avatar
 
Join Date: Oct 2004
Location: UK
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Sayonara is an unknown quantity at this point
SELECT DISTINCT 'field_name'

__________________
Quote:
Originally Posted by liorean
Just remember that you code for the user, and the user visits you because what you code is good.
Sayonara is offline   Reply With Quote
Old 01-31-2005, 02:04 AM   PM User | #3
dswimboy
Regular Coder

 
dswimboy's Avatar
 
Join Date: Nov 2003
Location: mostly in Ann Arbor
Posts: 458
Thanks: 0
Thanked 0 Times in 0 Posts
dswimboy is an unknown quantity at this point
how wonderfully simple. this forum is excellent for stupid little questions like this
__________________
"There is more than one way to do it."
dswimboy is offline   Reply With Quote
Old 01-31-2005, 10:12 AM   PM User | #4
Sayonara
Regular Coder

 
Sayonara's Avatar
 
Join Date: Oct 2004
Location: UK
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Sayonara is an unknown quantity at this point
Isn't it nice when a language uses a sensible word for a command?
__________________
Quote:
Originally Posted by liorean
Just remember that you code for the user, and the user visits you because what you code is good.
Sayonara is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:03 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.