Query of Queries Select Top Alternative

Posted: August 26, 2009 in ColdFusion

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.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s