Getting Record Count w/o doing 2 queries.

2005-09-07 Thread pow
Hi everyone, Im executing the following query: SELECT * FROM table1 WHERE table1.field1 = 'A' AND table1.field2 = 'B' LIMIT 0,10 I also need to get the total record count for the above query, but without the limit clause (limit is for pagination purposes) Is there any way to extract this total

Re: Getting Record Count w/o doing 2 queries.

2005-09-07 Thread Eric McGrane
After you execute your select/limit statement you can execute select found_rows() It returns the number of rows thbat the previous query would have returned if the limit wasn't applied. See: http://dev.mysql.com/doc/mysql/en/information-functions.html. Regards, E Hi everyone, Im

Re: Getting Record Count w/o doing 2 queries.

2005-09-07 Thread Brent Baisley
Just add SQL_CALC_FOUND_ROWS to your select statement: SELECT SQL_CALC_FOUND_ROWS COUNT(*)...; The you can execute a special query to figure out how many rows would have been returned without the LIMIT clause. SELECT FOUND_ROWS(); On Sep 7, 2005, at 6:15 AM, pow wrote: Hi everyone, Im

Re: Getting Record Count w/o doing 2 queries.

2005-09-07 Thread Gleb Paharenko
Hello. You want to check out the FOUND_ROWS() function: http://dev.mysql.com/doc/mysql/en/information-functions.html BTW, similar question was asked recently. pow [EMAIL PROTECTED] wrote: Hi everyone, Im executing the following query: SELECT * FROM table1 WHERE

Re: Getting Record Count w/o doing 2 queries.

2005-09-07 Thread SGreen
RTFM - It is online, it has an index, and it is searchable: http://dev.mysql.com/doc/mysql/en/select.html (hint: look for the phrase how many rows on this page) If you looked in the index for rows, you would find the function ROW_COUNT() (which is close but not exactly what you wanted).

Re: Getting Record Count w/o doing 2 queries [sorry, left out one major piece of info]

2005-09-07 Thread pow
Very sorry for having troubled all regarding the seemingly stupid rtfm garnering request for help. But in my attempt to make the question as simple and succinct as possible, i forgot to state one EXTREMELY important chunk of information. I can't use SQLCALCFOUNDROWS because there is a subqry

Re: Getting Record Count w/o doing 2 queries [sorry, left out one major piece of info]

2005-09-07 Thread SGreen
Then eliminate the subquery and SQL_CALC_FOUND_ROWS will be an option for you again. If you would like some help refactoring your query, I volunteer. If I can't help, I know there are several others on the list just as capable as I (or more so). Shawn Green Database Administrator Unimin