Can't you use the num_rows funtion to provide the count?

George
----- Original Message -----
From: "mos" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 02, 2002 6:11 AM
Subject: Re: How to Count(*) with LIMIT


> I have a Where clause like:
>          select count(*) from table where ....  LIMIT 100
>
> Unfortunately the Count(*) ignores the LIMIT clause entirely. Why?
>
> It seems to me that if a "select * from table where ... limit 100" returns
> between 0 and 100 rows, you should be able to count it. Instead the count
> returns 55,000 or some ridiculously large number that has no bearing on
the
> # of rows that will actually be returned (because of the LIMIT clause).
> Since this is running on a webserver, I don't want it to physically count
> more than 100 rows. Some of the tables may be over 1 million rows and
> counting that many rows when only 100 rows are returned is overkill.
>
> Is there a way around this counting problem? The only solution I've come
up
> with is to traverse all the rows returned by counting them in a loop. This
> seems pretty lame and I'm hoping someone can come up with a better
solution.
>
> Mike
>
> sql,query
>
>
>
> ---------------------------------------------------------------------
> Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
<[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to