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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:27:59+00:00 2026-05-23T22:27:59+00:00

I am trying to query 5 separate tables in my mysql database, and display

  • 0

I am trying to query 5 separate tables in my mysql database, and display the actor with the most amount of items assigned to them. The table structures are as follows;

item
itemid | item | description | brand | date | time | path |

actor
actorid | name | actorthumb | bio |

brand
brandid | brandname | description | image |

movie
movieid | title | genre | year | moviethumb | synopsis|

request
requestid | userid | itemid | brandid | movieid | actorid | content | requestdate |

I presume I need to join the request, actor and items table together, using COUNT function count how many items are assigned to an actor, then use GREATEST to display the actor with the highest amount of items assigned to them?

The query to join all the tables is 
$query = "SELECT greatest i.*, a.*, b.*, m.*, r.* FROM item AS i, actor AS a, brand AS    b, movie AS m, request AS r
    WHERE r.itemid = i.itemid 
    AND r.actorid = a.actorid
    AND r.brandid = b.brandid
    AND r.movieid = m.movieid";

Please confirm the best way to do the above?

  • 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-23T22:27:59+00:00Added an answer on May 23, 2026 at 10:27 pm
    SELECT a.actorid, a.name
        FROM request r
            INNER JOIN actor a
                ON r.actorid = a.actorid
        GROUP BY a.actorid, a.name
        ORDER BY COUNT(DISTINCT r.itemid) DESC
        LIMIT 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to query a MySQL database using an array but I'm having trouble!
I have four tables in a MySQL database and I am trying to create
I am trying to execute a query against a MySQL database. The query is
Trying to query a 'Favorites' model to get a list of items a user
I'm trying to query a database view that's not located on the same server
I'm trying to query a table, fetch all records, and save the result as
I'm trying to query a set of buldings listed on a table, these buildings
I am trying to retrieve two counts from two separate tables into one SQL
I'm trying to select all fields in two separate tables as long as they're
I'm trying to speed up SELECT queries in MySQL tables which already have some

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.