Query of Queries Select Top Alternative

For years I've never been aware of a method to return only so many rows to the ColdFusion memory space using dbtype="query". I've always just ran the query then limited it down the code with things like <cfoutput query="q" maxrows="1">.

In a MSSQL query, you can limit the query like: SELECT TOP 1 FROM TABLE

This will not work with a query of queries.

Today I found a solution...

Move the maxrows attribute to the cfquery tag. For example: <cfquery name="q" dbtype="query" maxrows="1"> will return only the first row back to the memory space.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1. Contact Blog Owner