[thelist] help w/design of SQL query

rudy r937 at interlog.com
Thu Nov 14 17:25:01 CST 2002


> What is the best way to approach this? Do I pull everything at once
> first, then do the logic? Or do I pull the number of categories first
> then do queries based on the number of those?

the first of those two is by far the better approach

the second will give me heart failure

your query is straightforward --

select catname, itemname
  from items, cats
 where items.catid = cats.id
order by catname, itemname

if you were using coldfusion, you would then say --

<cfoutput group=catname>
<p>#catname#
<cfoutput><br />#itemname#</cfoutput>
</p>
</cfoutput>

the "logic" code for detecting category breaks will be substantially more
verbose in other scripting languages

notice how in coldfusion there's no thiscat=prevcat testing required

it's all done for you automatically by the GROUP= parameter

rudy




More information about the thelist mailing list