?
Solved

Finding the last row from cfquery

Posted on 2006-05-30
5
Medium Priority
?
2,986 Views
Last Modified: 2013-12-24
I have

<CFLOOP QUERY="MyInstallments">

<input .......>

bla...

</CFLOOP>

What I need to find is the very last row from the query (already sorted) so that I can apply <cfif>:

<cfif MyInstallments_Last_Row> .... <cfesle> ....</cfif>
0
Comment
Question by:JohnLucania
5 Comments
 
LVL 3

Expert Comment

by:siva350
ID: 16792771
try something like this
<cfquery name="getmax" datasource="db">
SELECT MAX(field_ID) AS maxID FROM Table
</cfquery>
0
 

Author Comment

by:JohnLucania
ID: 16792907
The query already exists (<CFLOOP QUERY="MyInstallments"> ).
My question is how to find the last row/record from the query.
0
 
LVL 7

Assisted Solution

by:ExpertAdmin
ExpertAdmin earned 1000 total points
ID: 16793070
Try this:

<CFLOOP QUERY="MyInstallments">

     <CFIF MyInstallments.CurrentRow EQ MyInstallments.RecordCount>

     ...Your last row logic here...

    </CFIF>


</CFLOOP>


M@
0
 
LVL 12

Accepted Solution

by:
mkishline earned 1000 total points
ID: 16793073
You can try either:

<cfloop query="MyInstallments" startrow="#MyInstallments.recordcount#">
  <!--- This will work best if you just want to manipulate or check the content from the last row --->
</cfloop>

or if you need to do something for every row in the query:

<cfloop query="MyInstallments">
  <cfif currentrow EQ MyInstallments.recordcount>
    <!--- Do something if this is the last row of your queryset --->
  <cfelse>
    <!--- Do something else if this isn't the last row --->
  </cfif>
</cfloop>
0
 

Author Comment

by:JohnLucania
ID: 16793236
great!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question