mos,
Thursday, May 02, 2002, 8:11:33 AM, you wrote:

m> I have a Where clause like:
m>          select count(*) from table where ....  LIMIT 100

m> Unfortunately the Count(*) ignores the LIMIT clause entirely. Why?

Because first of all SELECT is executed and then LIMIT is applied.

m> It seems to me that if a "select * from table where ... limit 100" returns
m> between 0 and 100 rows, you should be able to count it.

You can use functions that are present in programming languages (f.e.
mysql_num_rows() in C API).

m> Instead the count
m> returns 55,000 or some ridiculously large number that has no bearing on the
m> # of rows that will actually be returned (because of the LIMIT clause).
m> Since this is running on a webserver, I don't want it to physically count
m> more than 100 rows. Some of the tables may be over 1 million rows and
m> counting that many rows when only 100 rows are returned is overkill.

m> Is there a way around this counting problem? The only solution I've come up
m> with is to traverse all the rows returned by counting them in a loop. This
m> seems pretty lame and I'm hoping someone can come up with a better solution.

m> Mike





-- 
For technical support contracts, goto https://order.mysql.com/
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Egor Egorov
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com



---------------------------------------------------------------------
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