Skip to main content
Inspiring
May 24, 2011
Question

join query with cfoutput group

  • May 24, 2011
  • 2 replies
  • 556 views

Hi,

I have the problem with join query and output the goup by, can anyone helps please?

1: worked fine

<cfquery name="qOrgs" datasource="#GetDSN()#">

select org
from cat

</cfquery>

<cfoutput query="qOrgs" group="org">
#org#<br />

</cfoutput>

2: not work, not grouping and display duplicated.

<cfquery name="qOrgs" datasource="#GetDSN()#">

select org

  from user u
  inner JOIN cat c

  on u.userid= c.userid
</cfquery>

<cfoutput query="qOrgs" group="org">
#org#<br />

</cfoutput>

Thanks

This topic has been closed for replies.

2 replies

ilssac
Inspiring
May 24, 2011

To expand on Dan's answer;

The "group" property of the <cfoutput...> tag is fairly simplistic.  All it actuall does is conditionally output content whenever the value of the specified group column changes.

So if you do not use an ORDER BY clause in your SQL to group the values of that column together (or they don't naturally group because of the current state of the data in the database) then the output is probably not going to be as desired.

Inspiring
May 24, 2011

Add an order by clause to your query.