This is an old question, but for posterity.
<cfquery name="getname" datasource="dsn"> select * from table </cfquery> <cfif getname.recordcount>Do this</cfif>
cfif getname.recordcount works like a logical check. If nothing happens in the result set, it fails ... if it returns a record, which satisfies the boolean check.
To deploy. Suppose we select a specific field of type id , and we want to provide output for any condition:
It will look like this:
<cfquery name="getname" datasource="dsn"> select id from table </cfquery> <cfif getname.recordcount> <cfoutput query="getname"> #id#<br> </cfoutput> <cfelse> No records found. </cfif>
source share