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

  • SEARCH
  • Home
  • 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 3240064
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:02:33+00:00 2026-05-17T18:02:33+00:00

So my site’s main page display’s applications for a PMP. Users can rate these

  • 0

So my site’s main page display’s applications for a PMP. Users can rate these apps with ‘Like’, ‘Dislike’, or ‘Neutral/None’ (every app is rated Neutral/None by default.)

On the main page I wanted to list the games by the highest difference (So it would take the total Like’s and Dislike’s then add them together.) I’m having difficulty making an SQL statement to do this correctly.

My tables structures are like this:

appinfo:
   id;
   name;
   genre;
   ...

appinfo basically holds all the metadata for the app. Nothing about the rating.

Next, I have the apprating table:

apprating:
   username;
   app_id;
   rating;

This is where all the ratings are stored. Ratings are stored as a -1 (Dislike), 0 (Neutral/None), and 1 (Like). I was hoping with this structure it would be easier to setup the whole statement. Can anyone help me out with writing one? I ended up writing a ridiculously long one that doesn’t sort properly or display the rating number.

SELECT appinfo.title, appinfo.description, appinfo.username, appinfo.genre 
FROM appinfo 
LEFT JOIN appratings ON appinfo.id=appratings.app_id 
GROUP BY appinfo.id 
ORDER BY SUM(appratings.rating) DESC

Thanks SO MUCH for reading this through, just an SQL statement and correction on my evil SQL ways would be nice!

UPDATE:

So before there was a rating system, I would have my SELECT statement, then in PHP I’d mysql_fetch_array, then loop through and echo their details, effectively letting me do things such as:

...
<p class="description"><?php echo $gameinfo['description']; ?></p>
...

Which would grab the description of the game it was on and echo it. Now, description still works, but since I now have an odd system that involves using SUM with my Like’s/Dislike’s and a JOIN statement for appinfo.id and apprating.app_id, I’m now experiencing issues with

  1. Echoing the ID of the current game, (echoing $gameinfo['id'] doesn’t echo anything.)
  2. How can I get the SUM of the Like’s/Dislike’s and echo that?

UPDATE 2

The SQL statement allowed me to write echo $gameinfo['totalscore'] to get the Like/Dislike differences and I just had to add appinfo.id to the SELECT to be able to echo the ID.

  • 1 1 Answer
  • 2 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-05-17T18:02:34+00:00Added an answer on May 17, 2026 at 6:02 pm

    Your GROUP BY clause needs to include all of the columns from the SELECT list that aren’t being aggregated in some manner. You may happen to know that the description, title, and other details won’t change for a particular app, but the database engine doesn’t, so it needs
    to understand whether each selected column is fixed (as part of the GROUP BY) or aggregated (SUM, COUNT, MIN, MAX, etc.)

    SELECT appinfo.title, appinfo.description, appinfo.username, appinfo.genre, 
        SUM(appratings.rating) AS totalscore
    FROM appinfo LEFT JOIN appratings 
    ON appinfo.id=appratings.app_id 
    GROUP BY appinfo.title, appinfo.description, appinfo.username, appinfo.genre
    ORDER BY totalscore DESC
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My site has the following url format: www.mysite.com/Display.aspx?ID=128 However most users see the url
My site has urls like $shareurl = http://www.mysite.com/?view=main&title=here-is-some-title So if i put this url
site.com/link?p=2 give $_GET['p']==2 even though i've already made site.com/link rewrite to site.com/index.php?page=link So, i'm
My site uses an HTML5shiv for the benefit of Internet Explorer 6 users. What
my site is allow users to register with arabic/english names i am trying to
the site is resizable, so I can not use px, and sometimes it's a
Site for writers and readers, both groups will be non-technical users (writers will be
My site is like a search engine with 2 types of search. Type 1
My site has a login box in the Layout page on which every page
Site 1 has dll's for x amount of object and data calls. Can Site

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.