Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Search Results - DISTINCT (newbie here)

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,41554
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Search Results - DISTINCT (newbie here)
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Search Results - DISTINCT (newbie here) - 12/31/2006 6:57:42 AM   
  Spiff123

 

Posts: 1
Score: 0
Joined: 12/31/2006
Status: offline
I have an Access database being used for a company locator which consists of several hundred company names with address, city, state, zip, and phone for each. Using a .asp page a user can search by company name which returns all locations of that company (some companies have multiple locations throughout the US and some have just one). This works fine.

My table structure:

tblCompanyID
CompanyID
CompanyName
(this table houses each company with a unique identifier)

tblLocation_Details
LocationID
CompanyID
CompanyName
Address
City
State
etc

The first page of results for a search by city or state should return only one CompanyID. These unique companies should link to detail pages which would include all locations within the search parameter for that CompanyID. The logic is, one company can have as many as 1700 locations and the companies with 1 location are getting buried. This is a solution to give equal weight to all companies in the first search results screen.

What I would like to do is when searching by city or state, I'd like those companies with multiple locations in that city or state to appear only once in the returned list. It doesn't matter which of the multiples is returned. E.g.,

If for the state of CA there are:
Company A
Company B
Company C1
Company C2
Company C3
Company D

...I would like the results page to display:
Company A
Company B
Company C1
Company D

I have tried using SELECT DISTINCT CompanyName, but that only returns the company name. Is there a way that I can also return the City and State for that DISTINCT CompanyName.

Thank you in advance for any help you can offer.
 
 
Post #: 1
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Search Results - DISTINCT (newbie here) Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts