Whatever message this page gives is out now! Go check it out!

queryIsEmpty

Last update:
May 18, 2026
Determines whether a query object contains any rows and returns YES or NO.

Description

The function provides a simple and readable way to check whether a query contains any rows.
The function returns "YES" if the query is empty and "NO" if it contains data.

Syntax

queryIsEmpty(query)
ParameterTypeDescription
queryQuery (required)A ColdFusion query object to evaluate.

Return Value

String: Returns "YES" if the query has zero rows, or "NO" if it contains one or more rows.

Usage Notes

  • Equivalent to checking query.recordCount == 0.
  • Improves readability and standardizes query emptiness checks.
  • Returns string values ("YES" / "NO"), not boolean true/false.

Basic Usage


<cfscript>
    emptyQuery = queryNew("id,name", "integer,varchar");
    result1 = queryIsEmpty(emptyQuery); // YES
    writeOutput(result1)

    filledQuery = queryNew("id,name", "integer,varchar", [{id:1,name:"Test"}]);
    result2 = queryIsEmpty(filledQuery); // NO
    writeOutput(result2)
</cfscript>

Conditional Logic


<cfscript>
if (queryIsEmpty(myQuery)) {
    writeOutput("No data found");
} else {
    writeOutput("Processing " & myQuery.recordCount & " records");
}
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page