Greetings,

We have a few queries that we use against our product database. We pull these 
results, and only display 50 rows per page via our web interface (then use 
"next and back page" links). An example query is:

select distributer.short_desc,
 distributer.sku,
 distributer.avail_code,
 distributer.msrp,
 distributer.dealer, 
IF( ISNULL(distributer_classmap.description), 
 distributer.brand_code, 
 distributer_classmap.description 
   ),
 distributer.msrp - distributer.dealer as profit,
 distributer.family from distributer 
Left Join distributer_classmap on 
 distributer_classmap.code = distributer.brand_code 
where avail_code = ('AA' or 'A' or 'B') 
and 
(distributer.brand_code = ? or distributer_classmap.description = ?) 
LIMIT ?,50

What I need to do is be able to count the *total* number of results this query 
generates, so I can build the offset numbers for the proper number of "next 
page" links.

Since I am using a limit clause, if i were to count in my app how many rows 
there are I would get 50 as that is what the limit is set for.

The only other way I know of to get the total results is to use COUNT. I 
really am not that great with SQL, so I don't know how I would apply a count 
statement to the above SQL.

I would like to keep the counting of total results, along with the LIMIT'ed 
result statement into 1 query if possible. 

Any hints would be greatly appreciated.

I am using MySQL 4.1.13a

Thanks!

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to