Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8486985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:06:21+00:00 2026-06-10T21:06:21+00:00

I have this php/sql Query: $result = mysql_query( SELECT r.item_id, AVG(rating) AS avgrating, count(rating)

  • 0

I have this php/sql Query:

$result = mysql_query("
            SELECT r.item_id, AVG(rating) AS avgrating, count(rating) AS count, i.item, c.category
            FROM ratings AS r
            LEFT JOIN items AS i
            ON r.item_id = i.items_id
            INNER JOIN master_cat c
            ON c.cat_id = i.cat_id
            GROUP BY item_id 
            ORDER BY avgrating DESC 
            LIMIT 25;");

When I output this, count is correct, it shows how much votes certain items have received.

I simply want to add a WHERE count >= 10 clause but everything breaks. Obviously, when there are thousands of items, some will get one vote and have 100%. But that is not a good indicator. I want to print out items that have at least 10 votes (or count >= 10)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:06:22+00:00Added an answer on June 10, 2026 at 9:06 pm

    You should to use having instead where

    SELECT 
        r.item_id, AVG(rating) AS avgrating, 
        count(rating) AS count, i.item, c.category
    FROM 
        ratings AS r
        LEFT JOIN items AS i
            ON r.item_id = i.items_id
        INNER JOIN master_cat c
            ON c.cat_id = i.cat_id
    GROUP BY 
        item_id 
    HAVING
        count >= 10
    ORDER BY 
        avgrating DESC 
    LIMIT 25;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
lets say i have this query SELECT tags FROM myTABLE; and the result of
I have this PHP code to highlight the Query on search results. if (isset($_REQUEST['k'])){
I have this PHP page where the user can select and un-select items. The
I have this PHP snippet: <?php $colors = array('red','green','blue'); foreach ($colors as &$item) {
I have this mysql query using PHP and first part is working fine, but
I have following SQL query: $readNews_SQLselect = SELECT ; $readNews_SQLselect .= live, content, user,
I have this PHP script which i'm grabbing images from a directory and displaying
I have this PHP code in a loop for every post on the admin
i have this php code and keep on getting errors upon fixing each error.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.