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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:29:27+00:00 2026-06-15T21:29:27+00:00

I have a database with multiple content types and users, as well as a

  • 0

I have a database with multiple content types and users, as well as a separate database with likes. I’m trying to figure out which users have received the most likes for any of their content, no matter what the type.

I’ve been able to figure out queries for finding the most liked users by specific content types, but going with any content type is proving to be a bit more difficult.

It might be worth noting that there are millions of records in this database.

Here’s the work I’ve been doing on creating a query… I’m pretty sure it’s not correct!

SELECT picture.user_id, video.creator_id, post.author_id
FROM likes_service.likes
INNER JOIN prod.pictures picture ON likes.obj_id = picture.id
INNER JOIN prod.videos video ON likes.obj_id = video.id
INNER JOIN prod.posts post ON likes.obj_id = post.id
GROUP BY picture.user_id, video.creator_id, post.author_id
ORDER BY COUNT(picture.user_id), COUNT(video.creator_id), COUNT(post.author_id) DESC
LIMIT 20;

Could anybody please give me a hint or point me in the right direction? I feel like I’m getting close…

Thanks!

  • 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-15T21:29:28+00:00Added an answer on June 15, 2026 at 9:29 pm

    I think you want a UNION, not a multi-way JOIN.

    select objects.user_id user_id, sum(likes.like_count) like_count
    from (
        select user_id, id
        from prod.pictures
        union all
        select creator_id, id
        from prod.videos
        union all
        select author_id, id
        from prod.posts) objects
    join (select obj_id, count(*) likes_count
          from likes_service.likes
          group by obj_id) likes on likes.obj_id = objects.id
    group by user_id
    order by like_count desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple database with multiple tables. I can't figure out how to
I have a MySQL database with multiple tables, each of which have the same
I have a database with users and games. 1 game can have multiple users
I have multiple content types, but they all share some similarities. I'm wondering when
I have a Content Provider for a SQLite database that has multiple tables and
I have database with multiple tables in Microsoft SQL Server with schema in tables
I have a table in a SQLite database with multiple key fields (lang and
Currently I have a database with the following relationships: One Client has multiple Entities
I have setup multiple SQL Service Broker Queues in a database but have not
In my SQL database I have a query that turns values in multiple rows

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.