Copy link to clipboard
Copied
Hi,
I have the query with out put below for one field as an example
Status
------
yes
yes
yes
no
i want to be able to do the compare for ALL status in one field but don't know how to do it, Can anyone plz help? Thanks
<cfif all status = "yes" ---> display Yes
<cfelseif all status = No -- display No
<cfelse> Other
</cfif>
Copy link to clipboard
Copied
Let's say the query name is "qry" and the column name is "booln".
A query object is really an array.
<cfset display = "">
<cfif ArrayFindNoCase(qry.booln,"no") AND NOT ArrayFindNoCase(qry.booln,"yes")>
<cfset display = "no">
<cfelseif ArrayFindNoCase(qry.booln,"yes") AND NOT ArrayFindNoCase(qry.booln,"no")>
<cfset display = "yes">
<cfelse>
<cfset display = "both">
<cfif>
HTH,
^_^
Copy link to clipboard
Copied
<cfset numberOfYeses = 0>
<cfoutput query="myQuery">
<cfif status EQ "yes">
<cfset numberOfYeses = numberOfYeses + 1>
</cfif>
</cfoutput>
<cfif numberOfYeses EQ myQuery.recordCount>
<!--- Then there were all Yeses --->
<cfelseif numberOfYeses EQ 0>
<!--- Then there were all Nos --->
<cfelse>
<!--- Then there were Yeses and Nos --->
</cfif>
Copy link to clipboard
Copied
Hi,
If your query name is "myquery" and the status column name is "status" then you can check like below:
<cfoutput query="myquery">
<br />
<cfif #myquery.status# eq "yes">
#myquery.status#
<cfelse>
#myquery.status#
</cfif>
</cfoutput>
If you want same status continuously then you can use order by in your query.