Unanswered: Can I count AND get this RS in a single statement?
I am running a SELECT to perform a user search:
- has 4 LEFT JOINS
- WHERE query depends on user search criteria
- LIMIT 50
The data itself has categories and sub categories. While displaying the results in the middle of the screen, I want to show for these results how many are in each category, and allow user to click on category to drill down. Ebay is a good example of this:
A search on books returns 100+ results, LIMIT 50. I also need the following breakdown from the results:
- Fiction (45)
- History (76)
- Non-Fiction (25)
Can I do this category breakdown count within the statement as above? Or do I need to have two statements, one SELECT for the results, and a second SELECT to return the category count?
This query will be performed a LOT so it has to be efficient.
Hi r937, thx for the reply but:
- Looping in script is not possible because I use a limit on results.
- This is all happening on one page. See ebay as an example.
- Found_Rows is used to count total rows (which I already do), it can't be used to count the categories.