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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:06:12+00:00 2026-06-11T09:06:12+00:00

This a follow up to the question I posed here . Using the same

  • 0

This a follow up to the question I posed here. Using the same kind of query, how do I make sure I get 10 movies back if there are restriction like ‘genre.name = ‘Classic Movies’ and ‘star.name = Humphrey Bogart.’ To be clear, the query must return data for 10 movies regardless of what the filtering restrictions are.

SELECT movie.id, movie.title, star.name, star.name_url, dir.name, 
       dir.name_url, genre.name, genre.name_url 
FROM 
        (SELECT * FROM movie WHERE movie.id > 0 ORDER BY movie.id LIMIT 10) movie
        LEFT JOIN actor 
             ON (movie.id = actor.movie_id) 
        LEFT JOIN person AS star 
             ON (actor.person_id = star.id) 
        LEFT JOIN director 
             ON (movie.id = director.movie_id) 
        LEFT JOIN person AS dir 
             ON (director.person_id = dir.id) 
        LEFT JOIN genre_classification 
             ON (movie.id = genre_classification.movie_id) 
        LEFT JOIN genre 
             ON (genre_classification.genre_id = genre.id)
  • 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-11T09:06:13+00:00Added an answer on June 11, 2026 at 9:06 am

    The issue is you’re selecting a list of 10 movies from the database with this sub-select:

    (SELECT * FROM movie WHERE movie.id > 0 ORDER BY movie.id LIMIT 10) movie
    

    If you’re trying to filter down that list more using a WHERE clause outside that sub-select, you could potentially get less than those 10 rows, as not all 10 could match your criteria. You could add that new criteria to the sub-select like so:

    (SELECT * FROM movie m INNER JOIN genre_classification g on g.movie_id = m.id and g.name = 'Classic Movies' WHERE m.id > 0 ORDER BY m.id LIMIT 10) movie
    

    This would do the same thing, but only give you (up to) 10 movies who had a matching genre of “Classic Movies”.

    This will, of course, still return more than 10 rows since you’re JOINing in actors, directors, other genres, etc. You should, however, have up to ten distinct movie IDs in the result set.

    Full Query:

    SELECT movie.id, movie.title, star.name, star.name_url, dir.name, 
           dir.name_url, genre.name, genre.name_url 
    FROM 
            (SELECT * FROM movie m INNER JOIN genre_classification g on g.movie_id = m.id and g.name = 'Classic Movies' WHERE m.id > 0 ORDER BY m.id LIMIT 10) movie
            LEFT JOIN actor 
                 ON (movie.id = actor.movie_id) 
            LEFT JOIN person AS star 
                 ON (actor.person_id = star.id) 
            LEFT JOIN director 
                 ON (movie.id = director.movie_id) 
            LEFT JOIN person AS dir 
                 ON (director.person_id = dir.id) 
            LEFT JOIN genre_classification 
                 ON (movie.id = genre_classification.movie_id) 
            LEFT JOIN genre 
                 ON (genre_classification.genre_id = genre.id)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a follow-on question from the one I asked here . Can constraints
This is a follow-up to a question I posted a while back: Can I
This post is a follow-up of a related question posted here by Ran .
This is a follow-up question to an answer I gave a few days back
This is a follow-up question to a question I posted here . I am
This is a follow-up question to the one I posted here (thanks to mario
This is a follow-up to an earlier question I posted on EF4 entity keys
This is a follow up on the question Android accesing soap service posted by
This is a follow up question from Calling constructor in return statement . This
This is a follow up question to a previous question I asked about calculating

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.