Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I'm stumped!

New Here ,
Jul 13, 2008 Jul 13, 2008
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!
248
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2008 Jul 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/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 13, 2008 Jul 13, 2008
LATEST
Azadi gave you some queries. The rest of it is:

<cfoutput query="yourquery">
#color#
<<hr />
</cfoutput>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources