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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:47:32+00:00 2026-06-17T16:47:32+00:00

I am using mysql database. I have two table one is user_songs and second

  • 0

I am using mysql database.
I have two table one is user_songs and second is user_like

Fields of user_song:

id(auto incement)
song_id
user_id
song_name
song_file

Fields of user_like:

id(auto incement)
song_id
uder_id
like

In user_like I am saving data where any user going like song so each row contain data like:

1 1 1 1

Please note like saves either 0 or 1.0 for dislike and 1 for like.

Now I need to find out top 20 most like songs id from user_like and get all data from user_songs from user_songs.

How to do this?
Thanks in advance to spend your valuable time to solve this query.

  • 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-17T16:47:32+00:00Added an answer on June 17, 2026 at 4:47 pm
    SELECT  a.*, b.totalLike
    FROM    user_song a
            INNER JOIN
            (
                SELECT  song_id, COUNT(*) totalLike
                FROM    user_like
                GROUP   song_id
            ) b ON a.song_id = b.song_ID
    ORDER BY totalLike DESC
    LIMIT 20
    

    Caution: the query above doesn’t handle tie up values on totaluserLike result. It will only display 20 records on the result list.

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

Sidebar

Related Questions

Okay, so let's say I have a mysql database table with two columns, one
I am using mysql database. I have two tables bugs and profiles. Bugs table
I am using Mysql database. I have 3 table-: table Column tier_price customer_id,sku(Unique),price,website catalog_product
I have two tables in one database. id | title --------- // table name
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I'm using a MySQL database. I have a products database where users can search
Suppose I am building an app using current mysql database tables. I have this
I am using CakePHP framework with MySQL database and I have problem in saving
I am using MySQL for my database. I have a requirement to store a
I have to store long strings in MySQL database using spring roo. I assumed

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.