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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T06:10:42+00:00 2026-06-08T06:10:42+00:00

I have the following query that has no errors: SELECT u.user_name, u.user_lastn, outer_s.movie_id, outer_s.times_rented

  • 0

I have the following query that has no errors:

SELECT u.user_name, u.user_lastn, outer_s.movie_id, outer_s.times_rented
FROM users u,
    ( 
        SELECT * FROM  
        (   
            SELECT user_id, movie_id, count (movie_id) as times_rented
            FROM movie_queue 
            GROUP BY (user_id, movie_id)
            ORDER BY user_id, movie_id 
        ) inner_s
        WHERE times_rented>1
    ) outer_s    
WHERE u.user_id= outer_s.user_id;

This is what it returns:

USER_NAME                USER_LASTN                 MOVIE_ID TIMES_RENTED
------------------------ ------------------------ ---------- ------------
John                     Smith                             1            3 
John                     Smith                             6            2 
Mary                     Berman                            4            2 
Mary                     Berman                            6            4 
Elizabeth                Johnson                           1            2 
Peter                    Quigley                           2            2 

What I still need to do is to show the name of the movie, instead of the movie_id, but
the name of the movies are located in another table named movies that is similar to the
following sample:

 MOVIE_ID  MOVIE_NAME                                                
---------- ---------------------------------------------
         1 E.T. the Extra-Terrestrial    
         2 Jurassic Park                
         3 Indiana Jones and the Kingdom of the Crystal     
         4 War of the Worlds  
         5 Signs  

Desired result:
What I want to see in the final table are the following columns:
USER_NAME | USER_LASTN | MOVIE_NAME | TIMES_RENTED |

Question:
But after all the many subqueries I am very confused, how can I get the movie_name there instead of the movie_id?

Attempted:
I tried getting the desired result by changing the query to

SELECT u.user_name, u.user_lastn, m.movie_name, outer_s.times_rented
FROM users u, movie m (etc.....)

But It returned 120 rows instead of the 6 I should get.

Help please!!

  • 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-08T06:10:46+00:00Added an answer on June 8, 2026 at 6:10 am
    SELECT u.user_name, u.user_lastn, m.movie_name, COUNT(q.movie_id)
    FROM users AS u
    JOIN movie_queue AS q ON q.user_id = u.user_id
    JOIN movie AS m ON m.movie_id = q.movie_id
    GROUP BY u.user_name, u.user_lastn, m.movie_name
    HAVING COUNT(q.movie_id) > 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following query that retrieve the number of users per country; SELECT
I have the following query that works well. SELECT DISTINCT city,region1,region2 from static_geo_world where
I have the following code: function user_name($id) { $eqpt_name1 = $this->sql->query(SELECT `f_val` FROM `profiles`
I have the following query with many LEFT JOIN clauses that has 7 result
I have the following query: $sql = SET @rownum := 0; SELECT * FROM
I have the following query that joins a bunch of tables. I'd like to
I have the following query that executes perfectly in MySQL, but it is giving
I have the following query that I want it to show Not Yet instead
I have the following query that runs in my Oracle database and I want
I have the following query that performs a AND on-demand: var products = //

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.