Re: Best way to tell how many rows a query returns
| From: | Bobo Wieland | Date: | Wed, 12 May 2004 08:53:35 +0000 |
| Subject: | Re: Best way to tell how many rows a query returns | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23681@lists.php.net to get a copy of this message | ||
Do this query first to get a variable that holds the total number of rows
matching your query....
count = mysql_result(mysql_query(SELECT COUNT(*) AS count FROM table WHERE
condition, $link_id),"count");
I think this is the correct syntax...
.bobo
----- Original Message -----
From: "Ross Honniball" <ross@bookshop.jcu.edu.au>
To: <php-windows@lists.php.net>
Sent: Wednesday, May 12, 2004 10:30 AM
Subject: [PHP-WIN] Best way to tell how many rows a query returns
> Hi folks,
>
> I'm using a mysql query with a LIMIT clause. The problem is I would like
to
> know how many rows WOULD have matched had the limit clause not been in
> place. I realise that any solution is going to involve some over-head, but
> what's the most efficient way to find out?
>
> eg.
>
> SELECT * FROM table WHERE conditions LIMIT 30,30
>
> Say there are 200 records that match 'conditions', only 30 rows are
> returned (of course). How do I find out the total number (200 in this
case)
> that matched the conditions?
>
> Any ideas?
>
> . Ross Honniball JCU Bookshop Cairns Supervisor
> . James Cook Uni, McGreggor Rd, Smithfield, Qld. 4878, Australia
> . Ph:07.4042.1157 Fx:07.4042.1158 Em:ross@bookshop.jcu.edu.au
> . There are no problems. Only solutions.
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>