Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT TOP in query of queries?

Status
Not open for further replies.

theotrain

Programmer
Mar 5, 2003
150
MX
i have a query of queries in coldfusion and i want to limit the results to a particular quantity.

ive read you can use

SELECT TOP 10 * FROM myTable ...

and that works for me in a query, but blows up when i try it in a query of queries for some reason. heres the code

<cfquery name="sortDistance" dbtype="query">
SELECT top 10 * from joinTables WHERE distance < #radius#
ORDER BY distance
</cfquery>

can anybody suggest an alternative way of achieving the same result? id like to limit the size of the query result itself and not simply display only part of the records.

thanks!
 
TOP blows up in QofQ because it isn't supported (it's not standard sql)

have you tried the MAXROWS parameter of the CFQUERY tag?

:)

r937.com | rudy.ca
 
im trying to avoid using maxrows, i would rather actually limit the size of the recordset in the query. im beginning to think now that my logic may be flawed though.

i was thinking that using maxrows is inefficient because its better to return a smaller recordset right from the query, and while i suppose thats normally true, i guess with a query of queries it doesnt really matter because you've already fetched a big-ass recordset from the db and how you dissect it from there isnt really going to matter much.

is that true?
 
yes, that's an accurate assessment

if you've already retrieved two, um, large result sets, using MAXROWS in query of query is fine

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top