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 766871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T17:07:03+00:00 2026-05-14T17:07:03+00:00

I just built a website and have realised that I need to have a

  • 0

I just built a website and have realised that I need to have a top 3 highest rated albums.. I haven’t built in something that keeps track of the ratings. Ratings are stored separately. Can someone show me how to put these together please.

SELECT id, name FROM albums LIMIT 3

SELECT rating FROM ratings WHERE url=CONCAT(‘albums/show/’, album.id)

Let me just flesh it out a bit. I need to get back the following:

From the albums table. id, name. From the ratings table I need to get back the average rating. ROUND((rating+rating+rating) / total ratings)

The ratings. Users can rate everything on my website so I have a generic ratings table. The rating is stored with the url of the page it applies to. Hence, to get album ratings I need to have ‘albums/show/{album_id}’. In hind sight I should have had a type and id field but it is a bit late now with a lunch iminient.

Any help is much appreciated.

  • 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-05-14T17:07:04+00:00Added an answer on May 14, 2026 at 5:07 pm
    SELECT
      a.id,
      a.name,
      AVG(r.rating) AS average
    FROM
        albums a
      LEFT JOIN
        ratings r
      ON
        r.url = CONCAT('albums/show/', a.id)
    GROUP BY
      a.id
    ORDER BY
      average DESC
    LIMIT 3
    

    (Untested, see AVG())

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've never done this before. The website I have just built is the second
I have had this website built for a few months and I am just
I have developed a dating website built on top of the Google App Engine,
I'm building a website to learn PHP and have just built a membership app.
I have a php built website with a mysql database. I need an sql
I've just inherited a website built with Ruby on Rails. I have never used
I have a website that I built using Django. Using the settings.py file, I
I have a client that just got the Apple Magic Mouse. We built a
I have joust built a website with a login system. After I've just got
I just built an application in ASP.net that returns a PNG image. The resulting

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.