Home > ASP Development > Non repeating results

Non repeating results



I need to create a menu from a db but I have repeating results e.g.



Slazenger

Slazenger

Gray Nicholls



when searching in a dataabse Slazenger appears twice as there are two instances in the search. I want to only display it once. Is there anyway to do a Select so it only appears once instead of how selecting it each time it appears within the database search.

Here is the code below i'd be greatful if someone could help, thanks very much.





John




Code:


<%
Cat = TRIM( Request.QueryString( "Cat" ))
%>
<%
Dim con, location
Set con = Server.CreateObject("ADODB.Connection")
location = Server.MapPath("db/shop.mdb")
con.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & location
Set RS = Server.CreateObject ( "ADODB.Recordset" )
RS.ActiveConnection = Con
RS.Open "Select * From tblproduct where cat='"&cat&"' "
'Loop Through Recordset
WHILE NOT RS.EOF
%>

<table width="200" border="1">
<tr>
<td>

<td>

<td><a href="shop.asp?Manufacturer=<%Response.Write RS( "Manufacturer" )%>&Cat=bats">
<%Response.Write RS( "Manufacturer" )%></a></td>


</tr>
</table>


<%
RS.MoveNext
WEND
%>



    
Guest


Hi,



use the DISTINCT Keyword,

try this as your query


Code:



RS.Open "Select DISTINCT Manufacturer From tblproduct where cat='"&cat&"' "




hope this helps

Was this answer helpful ? Yes No   
Guest


Whoops, Too slow!

Was this answer helpful ? Yes No   
Guest


Just Curiosity...is it possible to select more column using DISTINCT function.



for example table called department



fields: id and name where id is unique and name is reapiting



Select DISTINCT name From department works fine but i also want to show id as well



Viral

Was this answer helpful ? Yes No   
Guest


I have found it,



Select DISTINCT name, id From department



before this I was using



Select id, DISTINCT name From department that's why it wasn't working

Was this answer helpful ? Yes No   
Guest


no worries, glad its working now

Was this answer helpful ? Yes No   
Guest


Quote:
Originally Posted by nofriends
Hi,



use the DISTINCT Keyword,

try this as your query


Code:



RS.Open "Select DISTINCT Manufacturer From tblproduct where cat='"&cat&"' "




hope this helps




Thank you, it works fine now again, thank you very much for the help, im very greatful.





John

Was this answer helpful ? Yes No   
Guest


no problem John, have a great weekend

Was this answer helpful ? Yes No   
Guest
 
 
Home - About Infoqu - Contact - Privacy Statement - Link to Infoqu - Bookmark Infoqu

Copyright 2007-2008 by Infoqu. All rights reserved