SELECT DISTINCT Query not working

C

Chris

Please could someone take a look at following code .I want it to select
Distinct options but keep on getting multiple of the same selection.
eg:

Isat
Isat
Isat
Kemco

The choices are run from a database selection in a dropdown box.
Please could some one help.
Thanks Chris

Code follows
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""
<html>

<head>
<% ' FP_ASP -- ASP Automatically generated by a FrontPage Component. Do not
Edit.
FP_CharSet = "windows-1252"
FP_CodePage = 1252 %>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Sub Search</title>
</head>

<body bgcolor="#C0C0C0">

<!--webbot bot="DatabaseRegionStart"
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
r_type,Timestamp" s-columntypes="3,202,202,202,202,202,135"
s-dataconnection="Sublisting" b-tableformat="FALSE" b-menuformat="FALSE"
s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE"
b-tableheader="TRUE" b-listlabels="FALSE" b-listseparator="FALSE"
i-listformat="2" b-makeform="FALSE" s-recordsource="Results"
s-displaycolumns="Sublist" s-criteria="[Maincategory] EQ {Maincategory} +"
s-order="[Sublist] +" s-sql="SELECT DISTINCT * FROM Results WHERE
(Maincategory = '::Maincategory::') ORDER BY Sublist ASC"
b-procedure="FALSE" clientside suggestedext="asp"
s-defaultfields="Maincategory=" s-norecordsfound="No records returned."
i-maxrecords="256" i-groupsize="0" botid="0"
u-dblib="../../_fpclass/fpdblib.inc" u-dbrgn1="../../_fpclass/fpdbrgn1.inc"
u-dbrgn2="../../_fpclass/fpdbrgn2.inc" tag="BODY" preview="&lt;table
border=0 width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is
the start of a Database Results region. The page must be fetched from a web
server with a web browser to display correctly; the current web is stored on
your local disk or
network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
startspan --><!--#include file="../../_fpclass/fpdblib.inc"-->
<% if 0 then %>
<SCRIPT Language="JavaScript">
document.write("<div style='background: yellow; color: black;'>The Database
Results component on this page is unable to display database content. The
page must have a filename ending in '.asp', and the web must be hosted on a
server that supports Active Server Pages.</div>");
</SCRIPT>
<% end if %>
<%
fp_sQry="SELECT DISTINCT * FROM Results WHERE (Maincategory =
'::Maincategory::') ORDER BY Sublist ASC"
fp_sDefault="Maincategory="
fp_sNoRecords="No records returned."
fp_sDataConn="Sublisting"
fp_iMaxRecords=256
fp_iCommandType=1
fp_iPageSize=0
fp_fTableFormat=False
fp_fMenuFormat=False
fp_sMenuChoice=""
fp_sMenuValue=""
fp_sColTypes="&ID=3&Maincategory=202&Sublist=202&Remote_computer_name=202&Us
er_name=202&Browser_type=202&Timestamp=135&"
fp_iDisplayCols=1
fp_fCustomQuery=False
BOTID=0
fp_iRegion=BOTID
%>
<!--#include file="../../_fpclass/fpdbrgn1.inc"-->
<!--webbot bot="DatabaseRegionStart" endspan i-checksum="60817" --><ul>
<li>
<a target="_self"
href="Areaselect.asp?Sublist=<%=FP_FieldURL(fp_rs,"Sublist")%>">
<!--webbot bot="DatabaseResultColumn"
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
r_type,Timestamp" s-column="Sublist" b-tableformat="FALSE" b-hashtml="FALSE"
b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font
size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Sublist&lt;font
size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;"
startspan --><%=FP_FieldVal(fp_rs,"Sublist")%><!--webbot
bot="DatabaseResultColumn" endspan i-checksum="15449" --></a></li>
</ul>
<!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE"
b-menuformat="FALSE" u-dbrgn2="../../_fpclass/fpdbrgn2.inc" i-groupsize="0"
clientside tag="BODY" preview="&lt;table border=0
width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This is
the end of a Database Results
region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
startspan --><!--#include file="../../_fpclass/fpdbrgn2.inc"-->
<!--webbot bot="DatabaseRegionEnd" endspan i-checksum="65064" -->

</body>

</html>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""
 
T

TommyL

Hi Chris,

You Have
"SELECT DISTINCT * FROM Results WHERE.....
Change to
"SELECT DISTINCT FROM Results WHERE.....

See if that helps.. (dropping the * )

TL
| Please could someone take a look at following code .I want it to select
| Distinct options but keep on getting multiple of the same selection.
| eg:
|
| Isat
| Isat
| Isat
| Kemco
|
| The choices are run from a database selection in a dropdown box.
| Please could some one help.
| Thanks Chris
|
| Code follows
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""""""""""
| <html>
|
| <head>
| <% ' FP_ASP -- ASP Automatically generated by a FrontPage Component. Do
not
| Edit.
| FP_CharSet = "windows-1252"
| FP_CodePage = 1252 %>
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
| <title>Sub Search</title>
| </head>
|
| <body bgcolor="#C0C0C0">
|
| <!--webbot bot="DatabaseRegionStart"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-columntypes="3,202,202,202,202,202,135"
| s-dataconnection="Sublisting" b-tableformat="FALSE" b-menuformat="FALSE"
| s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE"
| b-tableheader="TRUE" b-listlabels="FALSE" b-listseparator="FALSE"
| i-listformat="2" b-makeform="FALSE" s-recordsource="Results"
| s-displaycolumns="Sublist" s-criteria="[Maincategory] EQ {Maincategory} +"
| s-order="[Sublist] +" s-sql="SELECT DISTINCT * FROM Results WHERE
| (Maincategory = '::Maincategory::') ORDER BY Sublist ASC"
| b-procedure="FALSE" clientside suggestedext="asp"
| s-defaultfields="Maincategory=" s-norecordsfound="No records returned."
| i-maxrecords="256" i-groupsize="0" botid="0"
| u-dblib="../../_fpclass/fpdblib.inc"
u-dbrgn1="../../_fpclass/fpdbrgn1.inc"
| u-dbrgn2="../../_fpclass/fpdbrgn2.inc" tag="BODY" preview="&lt;table
| border=0 width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the start of a Database Results region. The page must be fetched from a
web
| server with a web browser to display correctly; the current web is stored
on
| your local disk or
| network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdblib.inc"-->
| <% if 0 then %>
| <SCRIPT Language="JavaScript">
| document.write("<div style='background: yellow; color: black;'>The
Database
| Results component on this page is unable to display database content. The
| page must have a filename ending in '.asp', and the web must be hosted on
a
| server that supports Active Server Pages.</div>");
| </SCRIPT>
| <% end if %>
| <%
| fp_sQry="SELECT DISTINCT * FROM Results WHERE (Maincategory =
| '::Maincategory::') ORDER BY Sublist ASC"
| fp_sDefault="Maincategory="
| fp_sNoRecords="No records returned."
| fp_sDataConn="Sublisting"
| fp_iMaxRecords=256
| fp_iCommandType=1
| fp_iPageSize=0
| fp_fTableFormat=False
| fp_fMenuFormat=False
| fp_sMenuChoice=""
| fp_sMenuValue=""
|
fp_sColTypes="&ID=3&Maincategory=202&Sublist=202&Remote_computer_name=202&Us
| er_name=202&Browser_type=202&Timestamp=135&"
| fp_iDisplayCols=1
| fp_fCustomQuery=False
| BOTID=0
| fp_iRegion=BOTID
| %>
| <!--#include file="../../_fpclass/fpdbrgn1.inc"-->
| <!--webbot bot="DatabaseRegionStart" endspan i-checksum="60817" --><ul>
| <li>
| <a target="_self"
| href="Areaselect.asp?Sublist=<%=FP_FieldURL(fp_rs,"Sublist")%>">
| <!--webbot bot="DatabaseResultColumn"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-column="Sublist" b-tableformat="FALSE"
b-hashtml="FALSE"
| b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font
| size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Sublist&lt;font
| size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;"
| startspan --><%=FP_FieldVal(fp_rs,"Sublist")%><!--webbot
| bot="DatabaseResultColumn" endspan i-checksum="15449" --></a></li>
| </ul>
| <!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE"
| b-menuformat="FALSE" u-dbrgn2="../../_fpclass/fpdbrgn2.inc"
i-groupsize="0"
| clientside tag="BODY" preview="&lt;table border=0
| width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the end of a Database Results
| region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdbrgn2.inc"-->
| <!--webbot bot="DatabaseRegionEnd" endspan i-checksum="65064" -->
|
| </body>
|
| </html>
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""
|
|
|
 
T

TommyL

Chris,

Try this...

"SELECT DISTINCT Results FROM Maincategory"

"Results" being the table.. "Maincategory" the column

If this works then add the ordering (ORDER BY Sublist ASC)

TL

| Please could someone take a look at following code .I want it to select
| Distinct options but keep on getting multiple of the same selection.
| eg:
|
| Isat
| Isat
| Isat
| Kemco
|
| The choices are run from a database selection in a dropdown box.
| Please could some one help.
| Thanks Chris
|
| Code follows
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""""""""""
| <html>
|
| <head>
| <% ' FP_ASP -- ASP Automatically generated by a FrontPage Component. Do
not
| Edit.
| FP_CharSet = "windows-1252"
| FP_CodePage = 1252 %>
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
| <title>Sub Search</title>
| </head>
|
| <body bgcolor="#C0C0C0">
|
| <!--webbot bot="DatabaseRegionStart"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-columntypes="3,202,202,202,202,202,135"
| s-dataconnection="Sublisting" b-tableformat="FALSE" b-menuformat="FALSE"
| s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE"
| b-tableheader="TRUE" b-listlabels="FALSE" b-listseparator="FALSE"
| i-listformat="2" b-makeform="FALSE" s-recordsource="Results"
| s-displaycolumns="Sublist" s-criteria="[Maincategory] EQ {Maincategory} +"
| s-order="[Sublist] +" s-sql="SELECT DISTINCT * FROM Results WHERE
| (Maincategory = '::Maincategory::') ORDER BY Sublist ASC"
| b-procedure="FALSE" clientside suggestedext="asp"
| s-defaultfields="Maincategory=" s-norecordsfound="No records returned."
| i-maxrecords="256" i-groupsize="0" botid="0"
| u-dblib="../../_fpclass/fpdblib.inc"
u-dbrgn1="../../_fpclass/fpdbrgn1.inc"
| u-dbrgn2="../../_fpclass/fpdbrgn2.inc" tag="BODY" preview="&lt;table
| border=0 width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the start of a Database Results region. The page must be fetched from a
web
| server with a web browser to display correctly; the current web is stored
on
| your local disk or
| network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdblib.inc"-->
| <% if 0 then %>
| <SCRIPT Language="JavaScript">
| document.write("<div style='background: yellow; color: black;'>The
Database
| Results component on this page is unable to display database content. The
| page must have a filename ending in '.asp', and the web must be hosted on
a
| server that supports Active Server Pages.</div>");
| </SCRIPT>
| <% end if %>
| <%
| fp_sQry="SELECT DISTINCT * FROM Results WHERE (Maincategory =
| '::Maincategory::') ORDER BY Sublist ASC"
| fp_sDefault="Maincategory="
| fp_sNoRecords="No records returned."
| fp_sDataConn="Sublisting"
| fp_iMaxRecords=256
| fp_iCommandType=1
| fp_iPageSize=0
| fp_fTableFormat=False
| fp_fMenuFormat=False
| fp_sMenuChoice=""
| fp_sMenuValue=""
|
fp_sColTypes="&ID=3&Maincategory=202&Sublist=202&Remote_computer_name=202&Us
| er_name=202&Browser_type=202&Timestamp=135&"
| fp_iDisplayCols=1
| fp_fCustomQuery=False
| BOTID=0
| fp_iRegion=BOTID
| %>
| <!--#include file="../../_fpclass/fpdbrgn1.inc"-->
| <!--webbot bot="DatabaseRegionStart" endspan i-checksum="60817" --><ul>
| <li>
| <a target="_self"
| href="Areaselect.asp?Sublist=<%=FP_FieldURL(fp_rs,"Sublist")%>">
| <!--webbot bot="DatabaseResultColumn"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-column="Sublist" b-tableformat="FALSE"
b-hashtml="FALSE"
| b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font
| size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Sublist&lt;font
| size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;"
| startspan --><%=FP_FieldVal(fp_rs,"Sublist")%><!--webbot
| bot="DatabaseResultColumn" endspan i-checksum="15449" --></a></li>
| </ul>
| <!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE"
| b-menuformat="FALSE" u-dbrgn2="../../_fpclass/fpdbrgn2.inc"
i-groupsize="0"
| clientside tag="BODY" preview="&lt;table border=0
| width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the end of a Database Results
| region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdbrgn2.inc"-->
| <!--webbot bot="DatabaseRegionEnd" endspan i-checksum="65064" -->
|
| </body>
|
| </html>
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""
|
|
|
 
T

TommyL

OK Wake up... Sorry

"SELECT DISTINCT Maincategory FROM Results"

"Results" being the table.. "Maincategory" the column

That should work....

TL
| Please could someone take a look at following code .I want it to select
| Distinct options but keep on getting multiple of the same selection.
| eg:
|
| Isat
| Isat
| Isat
| Kemco
|
| The choices are run from a database selection in a dropdown box.
| Please could some one help.
| Thanks Chris
|
| Code follows
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""""""""""
| <html>
|
| <head>
| <% ' FP_ASP -- ASP Automatically generated by a FrontPage Component. Do
not
| Edit.
| FP_CharSet = "windows-1252"
| FP_CodePage = 1252 %>
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
| <title>Sub Search</title>
| </head>
|
| <body bgcolor="#C0C0C0">
|
| <!--webbot bot="DatabaseRegionStart"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-columntypes="3,202,202,202,202,202,135"
| s-dataconnection="Sublisting" b-tableformat="FALSE" b-menuformat="FALSE"
| s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE"
| b-tableheader="TRUE" b-listlabels="FALSE" b-listseparator="FALSE"
| i-listformat="2" b-makeform="FALSE" s-recordsource="Results"
| s-displaycolumns="Sublist" s-criteria="[Maincategory] EQ {Maincategory} +"
| s-order="[Sublist] +" s-sql="SELECT DISTINCT * FROM Results WHERE
| (Maincategory = '::Maincategory::') ORDER BY Sublist ASC"
| b-procedure="FALSE" clientside suggestedext="asp"
| s-defaultfields="Maincategory=" s-norecordsfound="No records returned."
| i-maxrecords="256" i-groupsize="0" botid="0"
| u-dblib="../../_fpclass/fpdblib.inc"
u-dbrgn1="../../_fpclass/fpdbrgn1.inc"
| u-dbrgn2="../../_fpclass/fpdbrgn2.inc" tag="BODY" preview="&lt;table
| border=0 width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the start of a Database Results region. The page must be fetched from a
web
| server with a web browser to display correctly; the current web is stored
on
| your local disk or
| network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdblib.inc"-->
| <% if 0 then %>
| <SCRIPT Language="JavaScript">
| document.write("<div style='background: yellow; color: black;'>The
Database
| Results component on this page is unable to display database content. The
| page must have a filename ending in '.asp', and the web must be hosted on
a
| server that supports Active Server Pages.</div>");
| </SCRIPT>
| <% end if %>
| <%
| fp_sQry="SELECT DISTINCT * FROM Results WHERE (Maincategory =
| '::Maincategory::') ORDER BY Sublist ASC"
| fp_sDefault="Maincategory="
| fp_sNoRecords="No records returned."
| fp_sDataConn="Sublisting"
| fp_iMaxRecords=256
| fp_iCommandType=1
| fp_iPageSize=0
| fp_fTableFormat=False
| fp_fMenuFormat=False
| fp_sMenuChoice=""
| fp_sMenuValue=""
|
fp_sColTypes="&ID=3&Maincategory=202&Sublist=202&Remote_computer_name=202&Us
| er_name=202&Browser_type=202&Timestamp=135&"
| fp_iDisplayCols=1
| fp_fCustomQuery=False
| BOTID=0
| fp_iRegion=BOTID
| %>
| <!--#include file="../../_fpclass/fpdbrgn1.inc"-->
| <!--webbot bot="DatabaseRegionStart" endspan i-checksum="60817" --><ul>
| <li>
| <a target="_self"
| href="Areaselect.asp?Sublist=<%=FP_FieldURL(fp_rs,"Sublist")%>">
| <!--webbot bot="DatabaseResultColumn"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-column="Sublist" b-tableformat="FALSE"
b-hashtml="FALSE"
| b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font
| size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Sublist&lt;font
| size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;"
| startspan --><%=FP_FieldVal(fp_rs,"Sublist")%><!--webbot
| bot="DatabaseResultColumn" endspan i-checksum="15449" --></a></li>
| </ul>
| <!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE"
| b-menuformat="FALSE" u-dbrgn2="../../_fpclass/fpdbrgn2.inc"
i-groupsize="0"
| clientside tag="BODY" preview="&lt;table border=0
| width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the end of a Database Results
| region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdbrgn2.inc"-->
| <!--webbot bot="DatabaseRegionEnd" endspan i-checksum="65064" -->
|
| </body>
|
| </html>
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""
|
|
|
 
K

Kevin Spencer

"SELECT DISTINCT Maincategory FROM Results"

This is the correct answer. For future reference, let me tell you why:

The DISTINCT Operator in SQL ensures that records that are identical are
combined into single records. Note that I said "records" not "columns." This
means that if you select more than one column in a record set, ALL columns
selected must be the same in order for 2 records to be combined. When you
use "SELECT *..." you are fetching ALL columns from the table, not just the
"Maincategory" column, and if, for example, that table has a primary key
field, such as an AutoNumber field, that field will not have the same value
in both records, and they will not be combined.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

TommyL said:
OK Wake up... Sorry

"SELECT DISTINCT Maincategory FROM Results"

"Results" being the table.. "Maincategory" the column

That should work....

TL
| Please could someone take a look at following code .I want it to select
| Distinct options but keep on getting multiple of the same selection.
| eg:
|
| Isat
| Isat
| Isat
| Kemco
|
| The choices are run from a database selection in a dropdown box.
| Please could some one help.
| Thanks Chris
|
| Code follows
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""""""""""
| <html>
|
| <head>
| <% ' FP_ASP -- ASP Automatically generated by a FrontPage Component. Do
not
| Edit.
| FP_CharSet = "windows-1252"
| FP_CodePage = 1252 %>
| <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
| <title>Sub Search</title>
| </head>
|
| <body bgcolor="#C0C0C0">
|
| <!--webbot bot="DatabaseRegionStart"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-columntypes="3,202,202,202,202,202,135"
| s-dataconnection="Sublisting" b-tableformat="FALSE" b-menuformat="FALSE"
| s-menuchoice s-menuvalue b-tableborder="TRUE" b-tableexpand="TRUE"
| b-tableheader="TRUE" b-listlabels="FALSE" b-listseparator="FALSE"
| i-listformat="2" b-makeform="FALSE" s-recordsource="Results"
| s-displaycolumns="Sublist" s-criteria="[Maincategory] EQ {Maincategory} +"
| s-order="[Sublist] +" s-sql="SELECT DISTINCT * FROM Results WHERE
| (Maincategory = '::Maincategory::') ORDER BY Sublist ASC"
| b-procedure="FALSE" clientside suggestedext="asp"
| s-defaultfields="Maincategory=" s-norecordsfound="No records returned."
| i-maxrecords="256" i-groupsize="0" botid="0"
| u-dblib="../../_fpclass/fpdblib.inc"
u-dbrgn1="../../_fpclass/fpdbrgn1.inc"
| u-dbrgn2="../../_fpclass/fpdbrgn2.inc" tag="BODY" preview="&lt;table
| border=0 width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the start of a Database Results region. The page must be fetched from a
web
| server with a web browser to display correctly; the current web is stored
on
| your local disk or
| network.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdblib.inc"-->
| <% if 0 then %>
| <SCRIPT Language="JavaScript">
| document.write("<div style='background: yellow; color: black;'>The
Database
| Results component on this page is unable to display database content. The
| page must have a filename ending in '.asp', and the web must be hosted on
a
| server that supports Active Server Pages.</div>");
| </SCRIPT>
| <% end if %>
| <%
| fp_sQry="SELECT DISTINCT * FROM Results WHERE (Maincategory =
| '::Maincategory::') ORDER BY Sublist ASC"
| fp_sDefault="Maincategory="
| fp_sNoRecords="No records returned."
| fp_sDataConn="Sublisting"
| fp_iMaxRecords=256
| fp_iCommandType=1
| fp_iPageSize=0
| fp_fTableFormat=False
| fp_fMenuFormat=False
| fp_sMenuChoice=""
| fp_sMenuValue=""
|
fp_sColTypes="&ID=3&Maincategory=202&Sublist=202&Remote_computer_name=202&Us
| er_name=202&Browser_type=202&Timestamp=135&"
| fp_iDisplayCols=1
| fp_fCustomQuery=False
| BOTID=0
| fp_iRegion=BOTID
| %>
| <!--#include file="../../_fpclass/fpdbrgn1.inc"-->
| <!--webbot bot="DatabaseRegionStart" endspan i-checksum="60817" --><ul>
| <li>
| <a target="_self"
| href="Areaselect.asp?Sublist=<%=FP_FieldURL(fp_rs,"Sublist")%>">
| <!--webbot bot="DatabaseResultColumn"
|
s-columnnames="ID,Maincategory,Sublist,Remote_computer_name,User_name,Browse
| r_type,Timestamp" s-column="Sublist" b-tableformat="FALSE"
b-hashtml="FALSE"
| b-makelink="FALSE" clientside b-MenuFormat preview="&lt;font
| size=&quot;-1&quot;&gt;&amp;lt;&amp;lt;&lt;/font&gt;Sublist&lt;font
| size=&quot;-1&quot;&gt;&amp;gt;&amp;gt;&lt;/font&gt;"
| startspan --><%=FP_FieldVal(fp_rs,"Sublist")%><!--webbot
| bot="DatabaseResultColumn" endspan i-checksum="15449" --></a></li>
| </ul>
| <!--webbot bot="DatabaseRegionEnd" b-tableformat="FALSE"
| b-menuformat="FALSE" u-dbrgn2="../../_fpclass/fpdbrgn2.inc"
i-groupsize="0"
| clientside tag="BODY" preview="&lt;table border=0
| width=&quot;100%&quot;&gt;&lt;tr&gt;&lt;td
| bgcolor=&quot;#FFFF00&quot;&gt;&lt;font color=&quot;#000000&quot;&gt;This
is
| the end of a Database Results
| region.&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;"
| startspan --><!--#include file="../../_fpclass/fpdbrgn2.inc"-->
| <!--webbot bot="DatabaseRegionEnd" endspan i-checksum="65064" -->
|
| </body>
|
| </html>
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
| """"""""""""""""""""""""""""""""""
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top