You might be better off looking to create one query that holds all the needed data. Then, and it sounds like this is the way to go from your explanation, look at using the group attribute of cfoutput when looping over your query.
Adrian > -----Original Message----- > From: Christina K [mailto:[email protected]] > Sent: 17 December 2008 20:18 > To: cf-newbie > Subject: simulate where clause in cfif statement > > I'm probably going to do a horrible job of explaining this, but here > goes... > > I've got this table on a page that I'm trying to output to that uses > two queries to get population data. The first query goes to an old > table that has all of the values stored in separate columns, so I just > have to select all of them and output each value where I want it. The > second query goes to a new column that stores the data by category, so > for 1 city I would have 18 different categories of data. My problem > is, I don't want to write 18 different queries each containing a Where > clause to identify the individual categories. But when I select all of > the data how do I let my cfoutput know which category's data to output > in that particular cell? > > I've tried using a loop and tried an array but because one column of > data (from the first query) has a different value output in each row, > whereas the other column doesn't, they don't work. What I'd like to do > is simulate what the Where clause in the SQL would do but inside the > table, perhaps as an if statement? Something like this: > > <Cfquery Name="rstPopAge"> > selects lots of stuff you don't really need to see...... > > <cfquery name="SemPopAge"> > SELECT pop2035, category > FROM rdf_dba.rdf2035_pop_agegroup > WHERE semmcd = #local_semmcd# > ORDER BY category > </cfquery> > > <tr> > <td class="item" width=62 align="left"> 85 and over</td> > <td class="data" width=56 > align="right"><cfoutput>#LsNumberFormat(rstPopAge.age01_00, > "999,999,999")#</cfoutput></td> > <cfif SemPopAge.category eq 1> > <td class="data" width=56 > align="right"><cfoutput>#LsNumberFormat(SemPopAge.pop2035, > "999,999")#</cfoutput> </td> > </cfif> > <td class="data" width=56 > align="right"><cfoutput>#LsNumberFormat(SemPopAge.pop2035 - > rstPopAge.age01_00, "999,999,999")#</cfoutput></td> > </tr> > > The if statement doesn't work and I don't even know if it's possible to > do what I want in this way. Any suggestions? > > Lastly, if it seems I have serious holes in my knowledge, it's because > I do. Sorry! I've had no formal training in CF and the learning > position I was hired for has turned out to be more self-learning than > anything. I really appreciate all the help I've gotten on this forum! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;207172674;29440083;f Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4239 Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
