Getting count of items with more than x reviews

This is a discussion on Getting count of items with more than x reviews within the MySQL Database forums, part of the Database Forums category; For some reason I am having such an issue coming up with a query to tell me the total number ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-16-2007
Ehask
 
Posts: n/a
Default Getting count of items with more than x reviews

For some reason I am having such an issue coming up with a query to
tell me the total number of items in one table that have more than X
numbers of reviews

2 Tables

Items & Reviews they both have item_id column (as index) Reviews
table has an account_id and review_text column

Can someone help me

Reply With Quote
  #2 (permalink)  
Old 11-16-2007
Rik Wasmus
 
Posts: n/a
Default Re: Getting count of items with more than x reviews

On Fri, 16 Nov 2007 20:18:49 +0100, Ehask <ehask71@gmail.com> wrote:

> For some reason I am having such an issue coming up with a query to
> tell me the total number of items in one table that have more than X
> numbers of reviews
>
> 2 Tables
>
> Items & Reviews they both have item_id column (as index) Reviews
> table has an account_id and review_text column


SELECT i.item_id, COUNT(r.item_id) as number_of_reviews
FROM items i
JOIN reviews r
ON r.item_id = i.item_id
GROUP BY i.item_id
HAVING number_of_reviews > X
--
Rik Wasmus
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:02 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0