?
Solved

Coldfusion - query to list question

Posted on 2016-10-19
3
Medium Priority
?
86 Views
Last Modified: 2016-10-19
Hello experts .
I need help to output two columns in a list.
I have a code that is working and i'm getting the output i need but i was thinking if i can use another function to 'build' the output (f.e. array).
My code  :

<cfoutput query="data" group="#arguments.sorting#">
     <cfset ruleslist = ''/>
      <cfoutput>
       <cfset listitem = 'testname_' & testname_id &  '=' &  testname_value/>
       <cfset ruleslist = listappend(ruleslist,listitem,'&')/>
      </cfoutput>
        #ruleslist#</br>
</cfoutput

Any help?
0
Comment
Question by:Panos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 41850278
AFAIK, there isn't a cleaner method when dealing with grouped query output.  Personally I don't see anything wrong with your current method.  Some db's like MySQL support functions like GROUP_CONCAT which allow you to build the "list" of values within your SQL, ie

          SELECT  ColumnToGroupBy
                         , GROUP_CONCAT(ColumnToBuildIntoList) AS YourList
          FROM    TableName
          GROUP BY ColumnToGroupBy

However, with all the concatenation required that might end up being less readable IMO.
0
 
LVL 2

Author Comment

by:Panos
ID: 41850316
Thank you very much for your help agx.
I'm sometimes wondering if there would be a better way of doing something.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 41850358
Yes, it's good to check the options when working on a section of code.  In this case, that code is probably as good as it gets. As using db functions, does not really buy anything.

Glad I could help.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question