Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strange GROUP behavior

Status
Not open for further replies.

pl12987

Programmer
Aug 2, 2001
53
US
The display code below should show the name of an author followed by the headlines of the articles written by the author. This works fine against a query that pulls all rows, but used on a query that displays only certain rows (called alphapull) I don't get the grouping...the author name repeats for each entry. The code is the same except for the query reference. Any insights appreciated:


<cfelseif param IS &quot;alpha&quot;>
<cfinclude template = &quot;alpha.cfm&quot;><p>
<cfoutput query = &quot;alphapull&quot; group = &quot;authorlastname&quot;>
<span class = &quot;displayonebold&quot;>#authorlastname#, #authorfirstname#</span><br>
<cfoutput>
<cfset newhead = &quot;#Replace(headline, &quot;''&quot;, &quot;&##146&quot;, &quot;ALL&quot;)#&quot;><span class = &quot;displayone&quot;>&##147;<a href = &quot;menarticleframe.cfm?articleid=#articleid#&quot; target = &quot;mainwin&quot;>#newhead#</a>&##148;</span>
<cfif #webonly# IS &quot;1&quot;>
   <img src = &quot;Images/webonly.jpg&quot;>
</cfif><br><span class = &quot;smalltext&quot;>           <b>CGNews:</b> #DateFormat(cgnewsdate, &quot;MMMM D, YYYY&quot;)#     <b>Original Publication: </b><i>#originalpub#</i>  #DateFormat(originalpubdate, &quot;MMMM D, YYYY&quot;)#</span><p>
</cfoutput><p>
</cfoutput>
<cfinclude template = &quot;alpha.cfm&quot;><p>
 
Here are my queries:

This runs if a user clicks on the alphabet bar:

<cfquery name = &quot;alphapull&quot; datasource = &quot;#dsn#&quot;>
SELECT menews.articleid AS articleid, menews.headline AS headline, menews.blurb AS blurb, menews.cgnewsdate AS cgnewsdate, menews.rank AS rank, menews.webonly AS webonly, menews.originalpub AS originalpub, menews.originalpubdate AS originalpubdate, menewsauthors.authorid AS authorid, menewsauthors.authorfirstname AS authorfirstname, menewsauthors.authorlastname AS authorlastname
FROM MENews, MENewsArticleAuthor, MENewsAuthors
WHERE MENewsAuthors.authorlastname LIKE '#letter#%' AND
MENews.articleid = MENewsArticleAuthor.articleid AND MENewsArticleAuthor.authorid = MENewsAuthors.authorid AND MENews.articleid != 100 AND MENews.articleid != 14
ORDER BY authorlastname, authorfirstname
</cfquery>

Otherwise this query runs:

<cfquery name = &quot;getinfo&quot; datasource = &quot;#dsn#&quot;>
SELECT menews.articleid AS articleid, menews.headline AS headline, menews.blurb AS blurb, menews.cgnewsdate AS cgnewsdate, menews.rank AS rank, menews.webonly AS webonly, menews.originalpub AS originalpub, menews.originalpubdate AS originalpubdate, menewsauthors.authorid AS authorid, menewsauthors.authorfirstname AS authorfirstname, menewsauthors.authorlastname AS authorlastname
FROM MENews, MENewsArticleAuthor, MENewsAuthors
WHERE
MENews.articleid = MENewsArticleAuthor.articleid AND MENewsArticleAuthor.authorid = MENewsAuthors.authorid AND MENews.articleid != 100 AND MENews.articleid != 14
ORDER BY <cfif param IS &quot;author&quot;>authorlastname, authorfirstname
<cfelseif param IS &quot;cgnewsdate&quot;>
cgnewsdate DESC
<cfelseif param IS &quot;originalpubdate&quot;>
originalpubdate DESC
</cfif>
</cfquery>
 
Your cfoutput group code looks fine to me and the query code looks good too, however are there are any other queries with the name &quot;alphapull&quot;, if executed after this version then they could overwrite the query.

If not, I think the problem is coming from the query. It's somehow not ordering the query in the correct format. The GroupBy attribute only works the way you want it to if the query outputs correctly with records grouped together.

Are there any conditions for the following line in the alphapull query?
ORDER BY authorlastname, authorfirstname - tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top