SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 20th, 2004, 01:35 PM
Frost Frost is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 448 Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 27 m 31 sec
Reputation Power: 8
Select Distinct

Ok, I'm not sure why this isn't working. I have a simple query, where I need one feild to just return the distinct records, and the other to return whatever is in it.


SQLQuery = "SELECT DISTINCT STREETDESCRIPTION, CIVIC FROM Address_Data order by STREETDESCRIPTION"

This however does not return the distinct streetdescription, but instead returns a bunch of duplicates. I have to remove, the Civic column out of the query to get the Streetdescription to be unique.

How can I correct this? Do I need to create a loop and have a seperate Streetdescription query and civc query? That seems to be a bit much.

any hellp would be greatly appreciated,
thanks.

Reply With Quote
  #2  
Old April 20th, 2004, 01:52 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,781 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 45 m 55 sec
Reputation Power: 470
Code:
SELECT DISTINCT StreetDescription, Civic
FROM Address_Data
GROUP BY StreetDescription

You will get duplicate StreetDescriptions if you have something like this
Code:
StreetDescription  Civic
A                        1
A                        2
A                        3
etc...

Because it is also pulling the DISTINCT Civic field, and all of those above would be distinct.

Reply With Quote
  #3  
Old April 20th, 2004, 01:55 PM
Frost Frost is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 448 Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level)Frost User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 3 Days 27 m 31 sec
Reputation Power: 8
hmm, well what the query is for, is to populate a dropdown list of streetdescriptions for the user to choose from. There is also a text box for the user to type in a Civic address, which is not a dropdown.

The reason included the civic number was for the variable to be passed to another page after they have populated the fields. Maybe I don't need the civic number in the query then.

??

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Select Distinct


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 1 hosted by Hostway
Stay green...Green IT