Ask a Question related to Macromedia ColdFusion, Design and Development.
-
Steve Grosz #1
How to limit # of rows returned from query
I am looking at setting a limit to the number of rows returned on some
of my queries.
I was looking at doing something like:
<cfoutput query="test" maxrows="5">
But when I tested this, it returned more than 5 rows. How would I
accomplish this? Also, if I wanted to indicate after the last row that
there were 'more' results to view, how can I do that, and then have a
user click the 'more results' or whatever the text will be to see the
other results?
Thanks!
Steve
Steve Grosz Guest
-
Limit the Number of Characters Returned
I am running into a problem with a dynamically created Select Box being too wide due to the names included in it. How can I limit the length of the... -
Deleting specific rows from a returned query result
I execute a <cfquery> statement block, and that works fine. However, I need to manipulate the return query rows by deleting the ones that do not... -
Limit Data returned to table
Hi I have a number of large fields of data being returned and would like to limit the amount of each one that is put to my table for viewing.... -
limiting rows returned in a sql select
ceprnatwork@hotmail.com (the dragon) wrote in message news:<6e59cc25.0308200651.6edb0e2@posting.google.com>... I dont know why "fetch first ...",... -
connecting to db2 from command line displays no rows returned
Hi, Just restored a DB, when accessing it from the comamnd line, I sometimes get $ db2 connect to SALESD Database Connection Information ... -
Cole #2
Re: How to limit # of rows returned from query
use the maxrows attribute of the cfquery tag, not cfoutput
Cole Guest
-
Steve Grosz #3
Re: How to limit # of rows returned from query
And what about the rest of the question. When there are more than
maxrows, how to either display on a 2nd page, or have a button to push
letting the user know there are more rows to return?
Cole wrote:> use the maxrows attribute of the cfquery tag, not cfoutputSteve Grosz Guest
-
Cole #4
Re: How to limit # of rows returned from query
if you use maxrows, there will never be more rows than what you specify. If
your looking to break up a large dataset, you might investigate one of the many
cf_paging tags available in the coldfusion exchange
Cole Guest
-
Latino #5
Re: How to limit # of rows returned from query
If you want to limit the numbers of row returned in your query, you might try
this, asumming you are using mySQL as your database.
<cfquery name='' datasource=''>
select *
from tableName
LIMIT 5
</cfquery>
Then in your cfoutput,
<cfoutput query=''>
Will only return 5 rows...
</cfoutput>
Hope this works for you
[url]http://www.tecito.com[/url]
Latino Guest
-
sillyworm #6
Re: How to limit # of rows returned from query
Hi Steve,
The first part should work the way you're doing it using the maxrows
attribute. Post your entire code to see why you might be returning more than 5
results. For paging, you simply want to use the startrow attribute. So in your
query, return all the rows, then, on each page, use something like <cfoutput
startrow="startVariable" maxrows="endVariable">
sillyworm Guest
-
Steve Grosz #7
Re: How to limit # of rows returned from query
I know why I'm returning more than 5 rows, because there are more than 5
entries in the database. I'm trying to make it easier for viewiers of
the page to get to the next group of entries, rather than having to
scroll down a long list of items returned.
sillyworm wrote:> Hi Steve,
>
> The first part should work the way you're doing it using the maxrows
> attribute. Post your entire code to see why you might be returning more than 5
> results. For paging, you simply want to use the startrow attribute. So in your
> query, return all the rows, then, on each page, use something like <cfoutput
> startrow="startVariable" maxrows="endVariable">
>Steve Grosz Guest
-
david_h #8
Re: How to limit # of rows returned from query
Steve, you'll have to use the startrow, maxrows attribute of the cfoutput,
however you may want to cache your query. If it's a heavy query your datbase
will have to re-run the query on every page.
What we do is put a query comment (we have a search id that we place in it)
tell CF to cache it within like 10 mins. So each time they do a new search
they get a new id, but as their paging (yes you need to pass the search id
around) they pull it from CF and there is no need for a trip to the DB again
Originally posted by: Latino
<cfquery name='' datasource=''>
select *
from tableName
LIMIT 5
</cfquery>
[url]http://www.tecito.com[/url]
Just a note...
You should not do it this way (sorry latino) but, when you tell a database to
do this, it gets the first 5 rows, then applies your where clause to it. if
it's a huge table with lots of varying data... you will not get correct results
david_h Guest



Reply With Quote

