Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 9th, 2003, 08:57 AM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default Distinct fields from mult columns

I have a access db with 4 different fields I need to get distinct info from. Each field has hundreds of duplicates...I want to get the distinct values for each column or field and put them in dropdown menus.

This is easy to do for one field or column.

<%
    sSQL = "SELECT DISTINCT Fund" & _
           " FROM MASTER_TABLE_cfoapal2" &_
           " ORDER BY Fund"
    set rs = Connect.Execute(sSQL)
%>
<snip>------------
<select name="dropdown1">
<% Do until rs.eof %>
 <option><%=rs("Fund")%></option>
<% rs.MoveNext
   Loop %>
</select>

I don't know how to do it for multiple fields...
I can't use SQL = "SELECT DISTINCT Fund" DISTINCT Org, because it gives me an error message. I also can't use sSQL = "SELECT Fund, Org", because I get hundreds of multiple entries for each of the two dropdowns.

How do I do this?
Do you need more information?

 
Old July 9th, 2003, 09:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

I think your only option with Access is to call it four times, once for each field...
 
Old July 9th, 2003, 09:30 AM
Authorized User
 
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default

What do you mean "call it four times"?

<%
    sSQL = "SELECT DISTINCT Fund" & _
           " FROM MASTER_TABLE_cfoapal2"
    set rs = Connect.Execute(sSQL)

    sSQL = "SELECT DISTINCT Org" & _
           " FROM MASTER_TABLE_cfoapal2"
    set rs = Connect.Execute(sSQL)
%>

Will something like this work?

 
Old March 18th, 2004, 12:44 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you found a solution to this? I have something similar.

sqlDrop1="SELECT ID,Manufacturer,Model FROM products"
sqlDrop1=sqlDrop1 & " WHERE Manufacturer LIKE '" & TOC & "'"
sqlDrop1=sqlDrop1 & " ORDER BY Model"

I want the ability to select the distinct of the model and only list one of each of the models in the above query. Currently, the above will show all the models (including duplicates).

master@notbound.com

 
Old March 18th, 2004, 12:47 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 205
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried:

sqlDrop1="SELECT DISTINCT ID,Manufacturer,Model FROM products"
sqlDrop1=sqlDrop1 & " WHERE Manufacturer LIKE '" & TOC & "'"
sqlDrop1=sqlDrop1 & " ORDER BY Model"





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting only rows with distinct columns. ThomasSQL SQL Server 2000 4 January 12th, 2006 04:49 PM
printing without printDialog on mult. printers frankv25 VB.NET 7 January 10th, 2005 11:42 AM
displaying multiple fields in columns rbegonia Classic ASP Basics 3 July 31st, 2004 08:37 PM
displaying multiple fields in columns rbegonia XSLT 0 July 29th, 2004 02:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.