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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:19:50+00:00 2026-05-29T06:19:50+00:00

Outer joins don’t seem to work whether I use a left outer join or

  • 0

Outer joins don’t seem to work whether I use a left outer join or right outer join:

SELECT * FROM `event_orchestra_musicians` eom
right outer join `orchestra_instruments` oi on eom.instrument_id = oi.oi_id
where event_id = 2
order by instrument_id

Orchestra_instruments contains different instruments with a unique ID i.e.:

  1. Violin
  2. Viola
  3. Harp
  4. Piccolo

Event_Orchestra_Musicians is a look up table to join musicians to an instrument i.e.:

musician_id, instrument_id, event_id, 
1 1 2
2 1 2
3 3 2
4 2 2

When I do any outer join, using the data in those tables, I would get the results of an inner join (Piccolo wouldn’t show up with a null musician_id, it wont show up at all). Is there something I’m doing wrong?

EDIT:

So I did some monkeying around. The issue seems to be because there is a record in the events_orchestra_musicians table with an event_id of 5 and an instrument_id of 7. If I remove that record, then the outer join works. What I don’t get is if that record is there and I use the where clause to look for event_id = 2, why does it matter if there’s a record in there with an instrument_id of 7 if its event_id is 5?

  • 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-29T06:19:51+00:00Added an answer on May 29, 2026 at 6:19 am

    Try this:

    select oi.oi_id, oi.instrument_name, eom.musician_id
    from orchestra_instruments oi
    left join event_orchestra_musicians eom on oi.oi_id = eom.instrument_id
    where (eom.event_id = 2 or eom.event_id is null)
    order by oi.oi_id
    

    You have to use orchestra_instruments as the base table, since that is the one you want all of the records for, even if no musician exists. I can’t imagine any reasons for using a Right join over a Left join, and Outer is implied. Also, you have to allow event_id to either be 2 or null, because it cannot be 2 if there is no matching record to join.

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

Sidebar

Related Questions

I don't understand the concept of a left outer join, a right outer join,
SELECT DISTINCT Database1.dbo.tblCustomers.SiteNum FROM Database1.dbo.tblCustomers LEFT OUTER JOIN tblWebUsers on tblWebUsers.SiteNum = Database1.dbo.tblCustomers.SiteNum WHERE
Left outer joins should return at least one row from the T1 table if
We are having a debate in our company. I use left outer joins quit
I have a right outer join, that almost does what I want... SELECT users_usr.firstname_usr,
Also, how do LEFT OUTER JOIN , RIGHT OUTER JOIN , and FULL OUTER
I can't seem to translate this to LINQ: select stuff FROM history INNER JOIN
hi i tried a select query that contains an left outer join on SQL
Wikipedia states: In practice, explicit right outer joins are rarely used, since they can
What is the difference between LEFT JOIN and LEFT OUTER JOIN ?

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.