MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here
  #1  
Old January 15th, 2004, 07:07 PM
uff8site uff8site is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 uff8site User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Distint Mysql

I was wondeirng if there is someway to do this. For example if i have a sql table that looks like this

NAME ADDRESS
JACK 1234 Street
JOE 2345 Street
JAMES 2349 Street
JOE 3459 Street

Is there a way to use the SELECT mysql query to show only the first JOE in my results and not the second along with the other names. Like I want it to show this when I use the SELECT QUERY:

NAME ADDRESS
JACK 1234 Street
JOE 2345 Street
JAMES 2349 Street

Please help. Thank you

Reply With Quote
  #2  
Old January 16th, 2004, 08:21 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Try this:
SELECT DISTINCT name, address FROM table;

Reply With Quote
  #3  
Old January 16th, 2004, 05:54 PM
uff8site uff8site is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 uff8site User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That wouldn't work because your statements is
SELECT DISTINCT name, address FROM table;
and since it tells MYSQL to select only the distinct name & address it'll still display all of them because no two are the same address and name. I only want it to show distinct base on name only not with address too.

Reply With Quote
  #4  
Old January 19th, 2004, 03:05 AM
uff8site uff8site is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 uff8site User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
*bump*

any help plz.... i really need this

Reply With Quote
  #5  
Old January 19th, 2004, 07:21 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Mabye SELECT DISTINCT(name), address FROM table?

Reply With Quote
  #6  
Old January 19th, 2004, 07:00 PM
uff8site uff8site is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 uff8site User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it didn't work neone else know how?

Reply With Quote
  #7  
Old January 19th, 2004, 07:27 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
what's the error you're getting?

have you tried simply doing SELECT DISTINCT name FROM table; then working up from there?

I trust you're replacing the word "table" with your tablename... (i noticed your post said table... just want to make sure)

Reply With Quote
  #8  
Old January 19th, 2004, 08:29 PM
uff8site uff8site is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 uff8site User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i'm not getting an error, yes i have been replacing the word table of course. The error is that it's not displaying what I need.

In the MYSQL database it has this info:
NAME ADDRESS
JACK 1234 Street
JOE 2345 Street
JAMES 2349 Street
JOE 3459 Street

However, I would like it to show
NAME ADDRESS
JACK 1234 Street
JOE 2345 Street
JAMES 2349 Street

Using SELECT DISTINCT name, address FROM table; would still display all 5 of the points from the MySQL table. I only want to show the distinct names, not the distinct names and addresses.

And refering to your comment of "have you tried simply doing SELECT DISTINCT name FROM table; then working up from there?", how would I work up from there, since that only displays the name and not the address.

Reply With Quote
  #9  
Old January 19th, 2004, 09:05 PM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,890 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 4 m 48 sec
Reputation Power: 8
Sorry to underestimate your knowledge... just had to make sure we were on the same page =)

I feel I fully understand your question... Its starting to bug me. I'm gonna help figure it out...

Reply With Quote
  #10  
Old January 20th, 2004, 07:44 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
No point getting snippy with the people who are trying to help you, uff8site.

Try a group by:

Code:
SELECT name, address FROM table GROUP BY name


This worked in a db I set up to test it.

Reply With Quote
  #11  
Old January 20th, 2004, 06:53 PM
uff8site uff8site is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 6 uff8site User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sorry... if my comment sounded repulsive in some way.... I just wanted to get my point across.

BTW, Thanks that worked

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Distint Mysql


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway