Skip to main content
Known Participant
July 13, 2008
Question

I'm stumped!

  • July 13, 2008
  • 2 replies
  • 267 views
This is my table:

PK COLOR
1 blue
2 orange
3 orange
4 red
5 red

In my cfoutput, I want to insert an "<hr>" before a new color is displayed. There is no pattern in the database

Its harder then it looks. Is a pure SQL solution possible? If not an CF solution? I'm stumped!
    This topic has been closed for replies.

    2 replies

    Inspiring
    July 13, 2008
    Azadi gave you some queries. The rest of it is:

    <cfoutput query="yourquery">
    #color#
    <<hr />
    </cfoutput>
    Inspiring
    July 13, 2008
    that's a strange data model... but then maybe your business logic
    dictates it to be so...

    what exactly is your requirement? do you need to select all PK as well,
    or just COLOR?

    you can try:
    SELECT DISTINCT color FROM yourtable - will get you distinct colors

    or

    SELECT pk, color
    FROM yourtable
    GROUP BY color
    ORDER BY color, pk

    you can also use a simple select query and cfoutput it with a GROUP
    attribute - details are in the cfml reference manual & livedocs

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/