Solved

Get Query Data

Posted on 2008-10-24
10
191 Views
Last Modified: 2013-12-24
I have the following results from a query;

getstats - query - Top 3 of 3 Rows
           CNO      ID            IID         STAT_FIRST1      STAT_LEVEL1      STAT_LAST1
1       101003       1073    R1232                   W                       5                        CLINE
2       101003       1093    R7653                    J                               4                        JONES
3       101003       1152    R7812                    A                       4                        SMITH

I am learning so please bear with me.
If I need to populate a form how do I get the values. For example if I need to retrieve the  STAT_FIRST1,      STAT_LEVEL1 and  STAT_LAST1 from the second row, how would I do this without running another query?
0
Comment
Question by:usky1
  • 5
  • 5
10 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22798876
in order to do this you do the following
In order to get the second record just say in your query where id=1093    
<cfoutput query="getstats ">
<input type="text" name="fieldname" value="#STAT_FIRST1#"
</cfoutput>
0
 

Author Comment

by:usky1
ID: 22798940
In the getstats query I need to query all the information for use later.
Is there any way that I can get the information without doing another query or query of queries?
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22798982
try is
<cfoutput query="getstats ">
<cfif getstats.recordcount  eq 2>
<input type="text" name="fieldname" value="#STAT_FIRST1#">
<cfif>
</cfoutput>
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:usky1
ID: 22799050
The getstats.recordcount is just giving me the total number of records and displaying two values for row 1 and for row 2.
0
 
LVL 19

Accepted Solution

by:
erikTsomik earned 500 total points
ID: 22799680
then try this
<cfoutput query="getstats ">

<input type="text" name="fieldname" <cfif currentrow eq 2>value="#STAT_FIRST1#"</cfif>>

</cfoutput>
0
 

Author Comment

by:usky1
ID: 22799923
The value was properly selected but it still produced two input fields, one with the correct value and one with an empty value.
 I changed the input to,
<cfif currentrow eq 2>
<input type="text" name="fieldname" <cfif currentrow eq 2>value="#STAT_FIRST1#"</cfif>>
</cfif>
And it is working now.
But is this a clean way to do what I need to?
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22800055
if you only need this you can just say in the query where id= to whatever number , IN this case you would not have to do this . However, is this always gonna look at the second row or it just a project specific

0
 

Author Comment

by:usky1
ID: 22800767
Sometimes it might need to look another row.
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22801433
then this condition is fine
0
 

Author Closing Comment

by:usky1
ID: 31509759
Thank you for your help.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 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