Distinct output using ASP/SQL

This is a discussion on "Distinct output using ASP/SQL" within the Classic ASP section. This forum, and the thread "Distinct output using ASP/SQL are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old May 29th, 2007, 16:55
New Member
Join Date: Mar 2007
Location: usa
Age: 50
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Distinct output using ASP/SQL

I'm having trouble with my output displaying only one link associated with one name. The output currently shows three links for each of the three names and the links are the same for all three. Meaning that each name should only have one associated link. The links are specific to each name. Below is the SQL code followed by an output example:

SQL Code:
Code: Select all
<%
set con = Server.CreateObject("ADODB.Connection")
con.Open "File Name=E:\webservice\Company\Company.UDL"
set rs = Server.CreateObject("ADODB.Recordset")

id=request.querystring("id")

IF id <> "" then id=id else id="9734" end if

'  This will apparently pull back too many records
strSQL = "SELECT DISTINCT GuestName, GuestDescription, URL, Description FROM T_ProgramGuests tpg LEFT JOIN T_ProgramLinks tpl ON tpl.ProgramID = tpg.programID WHERE (tpg.ProgramID = " & id & ")" 

rs.Open strSQL,con

previousGuestName = ""

While Not RS.Eof
    '  Only output guest details if this record has a different guest name to the previous one
    if previousGuestName <> cStr(rs("guestName")) then
        response.write "<br />" & vbcrlf
        response.write "<strong>" & rs("GuestName") & "</strong>"  & rs("GuestDescription") & "<br /><br />Related Links:<br />"  & vbcrlf
        previousGuestName = cStr(rs("guestName"))
    end if

    '  Always output the related links though
    response.write "<li class=""basic""><A HREF=""" & rs("URL") & """>" & rs("Description") & "</A></li>" & vbcrlf
    RS.MoveNext
Wend

recProgram.Close
con.Close
set recProgram = nothing
set con = nothing
%>
Example Output:

Greg Atkinson food writer, chef and regular contributor to the Cooking Klatch

Related Links:
# Brasa
# Greg Atkinson (This is specific to Greg and knowone else)
# Tom Douglas Restaurants

Tamara Murphy executive chef and owner of Brasa

Related Links:
# Brasa (This is specific to Tamara Murphy and knowone else)
# Greg Atkinson
# Tom Douglas Restaurants

Tom Douglas chef and owner of many restaurants around the Seattle area, including Lola, the Dahlia Lounge, Etta's and the Palace Kitchen

Related Links:
# Brasa
# Greg Atkinson
# Tom Douglas Restaurants (Specific to Tom Douglas)

What is wrong with my code that would cause this?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

Reply

Tags
asp, distinct, sql

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php output in to CSS dhossai Web Page Design 1 Oct 30th, 2007 18:38
delaying output theosx JavaScript Forum 6 Sep 19th, 2007 04:56
W3 validator has a distinct dislike to my doctype rubyfruit Starting Out 5 Jul 4th, 2007 17:30
output IE vs. FF jojo Web Page Design 5 Dec 29th, 2005 13:35
no output at all -- can't see why in code (???) jswebdev PHP Forum 8 Oct 16th, 2005 05:07


All times are GMT. The time now is 15:10.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42