Using an array rather than a list and then converting it at the end will be more efficient if you've got more than a few rows per column1 value. You should check your DB's docs too, as there might be a function that'll let you do with with SQL, rather than CF. MySQL has GROUP_CONCAT for exactly this purpose.
cheers, barneyb On 11/8/05, Baz <[EMAIL PROTECTED]> wrote: > > > > > > If I have the following query: > > > > Column1 || Column2 > > ValueA || ValueX > > ValueA || ValueY > > ValueB || ValueX > > ValueB || ValueY > > ValueB || ValueZ > > > > > > And I want to turn the second column into a list, while keeping the first > column unique - like so: > > > > Column1 || Column2 > > ValueA || ValueX, ValueY > > ValueB || ValueX, ValueY, ValueZ > > > > > > Is there a more efficient way to do this than: > > > > <cfoutput query="QueryXXX" group="Column1"> > > > > <!--- populate groups list ---> > > <cfoutput> > > <cfset > ColumnToList=listappend(ColumnToList,Column2) /> > > </cfoutput> > > > > <!--- add row to final query ---> > > <cfscript> > > queryaddrow(FinalQuery); > > querysetcell(FinalQuery,'Column1', > Column1); > > querysetcell(FinalQuery,'Column2', > ColumnToList); > > </cfscript> > > </cfoutput> > > > > I'm sure there's a million ways to do this… > > > > Baz > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites.
