limit stop count
How can I limit a count to stop when he reaches 200 rows? SELECT COUNT(*) FROM tbl WHERE where_clause;=> returns 3500 I want to stop the counting when it reaches to 200, so MySQL will not search further to count all the 3500 rows.. thanks, -Lorderon. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
RE: limit stop count
SELECT COUNT(*) FROM tbl WHERE where_clause limit 200; -Original Message- From: Lorderon [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 6:45 PM To: [EMAIL PROTECTED] Subject: limit stop count How can I limit a count to stop when he reaches 200 rows? SELECT COUNT(*) FROM tbl WHERE where_clause;=> returns 3500 I want to stop the counting when it reaches to 200, so MySQL will not search further to count all the 3500 rows.. thanks, -Lorderon. -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
Re: limit stop count
Nope.. that doesn't work.. the LIMIT statement limits the rows returned, but only 1 row is returned from that query always.. I want MySQL to stop the count when it reaches to 200, rather to have it go over all the table and return me 3500.. > SELECT COUNT(*) FROM tbl WHERE where_clause limit 200; > > -Original Message- > From: Lorderon [mailto:[EMAIL PROTECTED] > Sent: Wednesday, March 17, 2004 6:45 PM > To: [EMAIL PROTECTED] > Subject: limit stop count > > > How can I limit a count to stop when he reaches 200 rows? > > SELECT COUNT(*) FROM tbl WHERE where_clause;=> returns 3500 > > I want to stop the counting when it reaches to 200, so MySQL will not search > further to count all the 3500 rows.. > > > thanks, > -Lorderon. > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: limit stop count
At 1:52 +0200 3/18/04, Lorderon wrote: Nope.. that doesn't work.. the LIMIT statement limits the rows returned, but only 1 row is returned from that query always.. I want MySQL to stop the count when it reaches to 200, rather to have it go over all the table and return me 3500.. You can't tell COUNT() to stop counting at some point. But you can tell MySQL to stop producing rows with LIMIT. Select the rows into a different table, then return the count of the rows in that table. CREATE TEMPORARY TABLE tmp SELECT 1 FROM tbl WHERE where_clause LIMIT 200; SELECT COUNT(*) FROM tmp; DROP TABLE tmp; SELECT COUNT(*) FROM tbl WHERE where_clause limit 200; -Original Message- From: Lorderon [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 17, 2004 6:45 PM To: [EMAIL PROTECTED] Subject: limit stop count How can I limit a count to stop when he reaches 200 rows? SELECT COUNT(*) FROM tbl WHERE where_clause;=> returns 3500 I want to stop the counting when it reaches to 200, so MySQL will not search further to count all the 3500 rows.. thanks, > -Lorderon. -- Paul DuBois, MySQL Documentation Team Madison, Wisconsin, USA MySQL AB, www.mysql.com MySQL Users Conference: April 14-16, 2004 http://www.mysql.com/uc2004/ -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]