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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:04:31+00:00 2026-05-11T02:04:31+00:00

Ugh ok I’m terrible at explaining things, so I’ll just give you the quotes

  • 0

Ugh ok I’m terrible at explaining things, so I’ll just give you the quotes and links first:

Problem 4b (near bottom):

4b. List the film title and the leading actor for all of ‘Julie Andrews’ films.

movie(id, title, yr, score, votes, director)
actor(id, name)
casting(movieid, actorid, ord)
(Note: movie.id = casting.movieid, actor.id = casting.actorid)

My answer (doesn’t work):
    SELECT title, name
      FROM casting JOIN movie
              ON casting.movieid = movie.id
      JOIN actor
              ON casting.actorid = actor.id
     WHERE name = 'Julie Andrews'
       AND ord = 1

The problem here is that it wants the list of lead actors of movies with ‘Julie Andrews’ as an actor (who is not necessarily the lead actor), but all I’m doing with my answer is getting the movies where she is the lead (ord = 1).

How do I specify the list of lead actors without ‘Julie Andrews’ being it? I suspect I have to do something with GROUP BY, but I can’t figure out what at the moment…

Edit: Do I need to use a nested SELECT?

  • 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. 2026-05-11T02:04:31+00:00Added an answer on May 11, 2026 at 2:04 am

    There are wonderful ways of doing this with subqueries, but it appears that t this point in the tutorial you’re only working with JOINs. The following is how you would do it with only JOINs:

    SELECT   movie.title,   a2.name FROM   actor AS a1   JOIN casting AS c1 ON (a1.id = c1.actorid)   JOIN movie ON (c1.movieid = movie.id)   JOIN casting AS c2 ON (movie.id = c2.movieid)   JOIN actor AS a2 ON (c2.actorid = a2.id) WHERE    a1.name = 'Julie Andrews'   AND c2.ord = 1 

    EDIT (more descriptive):

    This will give us a table containing all of the movies Julie Andrews acted in. I’m aliasing the actor and casting tables as a1 and c1 respectively because now that we’ve found a list of movies, we’ll have to turn and match that against the casting table again.

    SELECT   movie.* FROM   actor a1   JOIN casting c1 ON (a1.id = c1.actorid)   JOIN movie ON (c1.movieid = movie.id) WHERE   a1.name = 'Julie Andrews' 

    Now that we have a list of all movies she acted, we need to join that against the casting table (as c2) and that to the actor table (as a2) to get the list of leading roles for these films:

    SELECT   movie.title,  -- we'll keep the movie title from our last query   a2.name       -- and select the actor's name (from a2, which is defined below) FROM   actor a1                                     -- \   JOIN casting AS c1 ON (a1.id = c1.actorid)   --  )- no changes here   JOIN movie ON (c1.movieid = movie.id)        -- /   JOIN casting AS c2 ON (movie.id = c2.movieid)  -- join list of JA movies to the cast   JOIN actor AS a2 ON (c2.actorid = a2.id)  -- join cast of JA movies to the actors WHERE    a1.name = 'Julie Andrews'  -- no changes   AND c2.ord = 1    -- only select the star of the JA film 

    Edit: In aliasing, the ‘AS’ keyword is optional. I’ve inserted it above to help the query make more sense

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

Sidebar

Related Questions

Ugh.. mod_rewrite makes me feel stupid. I just haven't wrapped my brain around it
So i've purposefully stayed away from RegEx as just looking at it kills me...ugh.
This is my first experience with javascript, and... Well... Ugh. Here's what's happening: function
Ugh. Word is notorious for its bloated, convoluted, non-standards-compliant, non-semantic HTML. Unfortunately, I have
I've written / modified a couple custom snippets via the Ruby bundles (Ugh, Yuck!)
I'm trying to help out a nonprofit by doing their website. They want (ugh)
''.join(list) is pretty great. However, I'm noticing that I very commonly have to add
UGH. Hi. I have a form. I'd like to know how/if I could submit
Ugh! Any ideas? Have a form which tracks user activity for given time intervals.
Can someone explain why the 1 was included in the first regex group instead

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.