ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old October 13th, 2004, 03:04 PM
JaviSRK JaviSRK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 58 JaviSRK User rank is Private First Class (20 - 50 Reputation Level)JaviSRK User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 13 h 16 m 11 sec
Reputation Power: 5
Question ColdFusion alternative to ASP's movenext

I think the title says it all.

I have a query that I want to run.
At this point, CFLOOP doesn't seem to be an option.
I want to execute the query, and if it meets a certain condition, I want it to go to the next record in the query.

Code:
<CFQUERY name=query1>
 SELECT * FROM QueryTable1
</CFQUERY>
<CFQUERY name=query2>
 SELECT * FROM QueryTable2
</CFQUERY>

<CFLOOP query=query1>
  blah blah blah
   <CFIF query.condition>"next record in query2"</CFIF>
</CFLOOP>


Or something like that. Thanks in advance!

Reply With Quote
  #2  
Old October 13th, 2004, 03:24 PM
jordonbedwell jordonbedwell is offline
Ultra Geek!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 294 jordonbedwell User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 52 m 19 sec
Reputation Power: 5
Quote:
Originally Posted by JaviSRK
I think the title says it all.

I have a query that I want to run.
At this point, CFLOOP doesn't seem to be an option.
I want to execute the query, and if it meets a certain condition, I want it to go to the next record in the query.

Code:
  <CFQUERY name=query1>
   SELECT * FROM QueryTable1
  </CFQUERY>
  <CFQUERY name=query2>
   SELECT * FROM QueryTable2
  </CFQUERY>
  
  <CFLOOP query=query1>
    blah blah blah
     <CFIF query2.condition>"QueryTable2movenext"</CFIF>
  </CFLOOP>
  


Or something like that. Thanks in advance!

You can use ifstatements.

Both in your query and outside of it to excute your querys.

<cftransaction>
<cfif blah IS "blah">
<cfquery>
SELECT BLAH1 FROM BLAH1 AND BLAH2
</cfquery>
<cfif blah2 IS NOT blah1>
<cfquery>
SELECT BLAH1 FROM BLAH2 and BLAH3
</cfquery>
</cfif>
</cfif>

Reply With Quote
  #3  
Old October 13th, 2004, 03:42 PM
JaviSRK JaviSRK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 58 JaviSRK User rank is Private First Class (20 - 50 Reputation Level)JaviSRK User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 13 h 16 m 11 sec
Reputation Power: 5
Quote:
Originally Posted by jordonbedwell
You can use ifstatements.

Both in your query and outside of it to excute your querys.

<cftransaction>
<cfif blah IS "blah">
<cfquery>
SELECT BLAH1 FROM BLAH1 AND BLAH2
</cfquery>
<cfif blah2 IS NOT blah1>
<cfquery>
SELECT BLAH1 FROM BLAH2 and BLAH3
</cfquery>
</cfif>
</cfif>


From my previous post, the <CFLOOP query=query1>
tag is necessary. So I'm really confused now.

Reply With Quote
  #4  
Old October 13th, 2004, 06:22 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
Quote:
Originally Posted by JaviSRK
I think the title says it all.

I have a query that I want to run.
At this point, CFLOOP doesn't seem to be an option.
I want to execute the query, and if it meets a certain condition, I want it to go to the next record in the query.

Code:
<CFQUERY name=query1>
 SELECT * FROM QueryTable1
</CFQUERY>
<CFQUERY name=query2>
 SELECT * FROM QueryTable2
</CFQUERY>

<CFLOOP query=query1>
  blah blah blah
   <CFIF query.condition>"next record in query2"</CFIF>
</CFLOOP>


Or something like that. Thanks in advance!

I'm unsure what you are trying to do. Loop over one query and if it meets some condition go to the next record in another query? I've never heard of such a thing and can't envision why you'd take this route. I can't tell if this is a situation where you really should combine the queries into one, or whether it's something you can do by looping over one or the other of the queries if they truly need to be separate (which from past experience I highly doubt). Please explain in more detail what exactly you are trying to do.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian.
How to Post a Question in the Forums

Reply With Quote
  #5  
Old October 18th, 2004, 02:37 PM
JaviSRK JaviSRK is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 58 JaviSRK User rank is Private First Class (20 - 50 Reputation Level)JaviSRK User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 13 h 16 m 11 sec
Reputation Power: 5
I hope I can explain this correctly. I've got a list of items in a database table(Items).
The fields that would be involved would be Itemname, Image, Group, SortOrder.
Group and SortOrder determines in what order the items would appear. The Group field would take precedence over the SortOrder field. If the list is at the end of a group, then a <hr> is inserted (to show the division between possible groups and the rest of the items without a group).

However, in my listing, I have an option from another table that allows for a value to be inserted for Columns. This option basically lets me set how many columns would appear in the listing (basically a dynamic table). I have it to where the list would list from top/bottom, as opposed to left/right.

Code:
<!--If the Columns value is set to '2' -->
<table><tr><td>
<table>Item1</table>
<table>Item2</table>
</td></tr><tr><td>
<table>Item3</table>
<table>Item4</table>
<table>Item5</table>
</td></tr></table>


In a group, I want it to appear as such:
Code:
<!--If the Columns value is set to '2' -->
<table><tr><td>
<table>Item10(group1)</table>
<table>Item11(group1)</table>
</td></tr><tr><td>
<table>Item12(group1)</table>
<table>Item13(group1)</table>
</td></tr></table>
<hr>
<table><tr><td>
<table>Item1</table>
<table>Item2</table>
</td></tr><tr><td>
<table>Item3</table>
<table>Item4</table>
<table>Item5</table>
</td></tr></table>


The reason I'm trying to create two querys:
One is to get the complete listing on the Items table.
SELECT * FROM Items
Order by Group, SortOrder
Two is to get the count of a certain group.
SELECT `group`, Count(*) as Kount
FROM Items
GROUP BY `group`
If the recordcount of the first query exceeds the Kount value of the 2nd query, I want the next row of the 2nd query.

Reply With Quote
  #6  
Old October 18th, 2004, 03:16 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,627 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 10 h 8 m 55 sec
Reputation Power: 53
I'm still not convinced that you can't do this with a single query and the proper aggregate functions. However, you could also do this by looping over the main query and calculating the group counts (omitting the second query), or you could use the query of queries functionality to run query against the existing query result set to determine the counts. Another option would be to take the second query and turn it into a structure that you could then use to look up the group count for any given group.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > ColdFusion alternative to ASP's movenext


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway