Skip to main content
Known Participant
July 12, 2008
Question

SQL select query help

  • July 12, 2008
  • 4 replies
  • 734 views
I know this is a SQL question but I can't seem to figure this out. The below SQL query will run without error however it will output the company_name for every row which I dont want.

So basicly it currently outputs like this now:
company_name - apple
company_name - dell

BUT want it to output like this:
company_name - apple,dell

MY CURRENT QUERY:

SELECT d.disputeid, t.company_name, t.tlid, t.type, l.description
FROM member_disputes d, member_tradeline t, letters l
WHERE d.fk_tlid = t.tlid
AND d.fk_letterid = l.letterid
AND d.fk_memberid = #GetAuthUser()#

Any help much appreciated

    This topic has been closed for replies.

    4 replies

    Inspiring
    July 13, 2008
    quote:

    Originally posted by: LionelR
    I know this is a SQL question but I can't seem to figure this out. The below SQL query will run without error however it will output the company_name for every row which I dont want.

    So basicly it currently outputs like this now:
    company_name - apple
    company_name - dell

    BUT want it to output like this:
    company_name - apple,dell

    MY CURRENT QUERY:

    SELECT d.disputeid, t.company_name, t.tlid, t.type, l.description
    FROM member_disputes d, member_tradeline t, letters l
    WHERE d.fk_tlid = t.tlid
    AND d.fk_letterid = l.letterid
    AND d.fk_memberid = #GetAuthUser()#

    Any help much appreciated



    Suddenly a light bulb illuminated over my head.

    <cfouput>
    company_name - #ValueList(yourquery.company_name)#
    </cfoutput>

    If that doesn't work, either change this, "t.company_name" to "company_name" or "t.company_name as company_name".

    I can't believe none of us thought of this earlier.
    Inspiring
    July 13, 2008
    What is your output code?
    Inspiring
    July 12, 2008
    Do two cfoutputs. In the first one, output your company names separated by commas. In the 2nd output whatever else you want to output.
    LionelR1Author
    Known Participant
    July 12, 2008
    I think it would be more efficent to tweak the existing SQL statement to do this rather then employing additional CF code to get the job done. I'm using MS SQL server.
    Inspiring
    July 12, 2008
    quote:

    Originally posted by: LionelR
    I think it would be more efficent to tweak the existing SQL statement to do this rather then employing additional CF code to get the job done. I'm using MS SQL server.

    Not if you want to display the other fields you selected.
    Inspiring
    July 12, 2008
    use the GROUP attribute of <cfoutput> tag. details are in the cfml
    reference manual / livedocs.

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    LionelR1Author
    Known Participant
    July 12, 2008
    <CFOUTPUT QUERY="getdisputes" group="company_name"> doesnt display properly. Can this not be done via the SQL statement?