Garayed.com  

Go Back   Garayed.com > mySQL
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-16-2007, 06:18 PM
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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-16-2007, 07:02 PM
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

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



All times are GMT. The time now is 08:27 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.