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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:52:17+00:00 2026-06-18T20:52:17+00:00

Ok, I am semi efficient with SQL and I tried using an OR statement

  • 0

Ok, I am semi efficient with SQL and I tried using an OR statement in a left join and found it didn’t work.

The reason for me doing this is because I have two columns from two tables that I am trying to use to join if one returns NULL. I have a two tables – events and seasons. Each table has a sponsor id column which I use to join the sponsors table. The reason behind this is because sometimes a single event is sponsored rather than the whole season or the other way around.

My question is whats the best way I can do this. My original query isn’t the same as this but its the same concept (except it doesn’t grab every column from every table).

SELECT sp.*, re.*, ev.*, se.* 
FROM events ev 
INNER JOIN seasons se ON se.season_id=ev.event_sid 
INNER JOIN results re ON ev.event_id=re.results_eid 
LEFT JOIN sponsors sp ON ev.event_sponsor=sp.sponsor_id

and at the end I tried to tack on OR se.season_sponsor=sp.sponsor_id

Ultimately I am trying to join the sponsors table with either ev.event_sponsor or se.season_sponsor. Any help is much appreciated. I did a little researching and couldn’t find an answer to what I was trying to accomplish.

  • 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-18T20:52:19+00:00Added an answer on June 18, 2026 at 8:52 pm

    Try:

    SELECT sp.*, re.*, ev.*, se.* 
    FROM events ev 
    INNER JOIN seasons se ON se.season_id=ev.event_sid 
    INNER JOIN results re ON ev.event_id=re.results_eid 
    LEFT JOIN sponsors sp ON COALESCE(ev.event_sponsor,se.season_sponsor)=sp.sponsor_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a semi-working example that you can look at. This appears to work
I noticed this semi weirdish-behavior in one of my projects using Scheme and lists.
This is semi-programming related. I'm working with more than 1 person on a website.
I'm using semi-transparent PNGs (due to the designer's overlapping of elements) and trying to
I'm using some semi-transparent PNGs as background-images on various websites. These are usually something
Semi-unimportant background: I'm working on a page with two sets of collapsable panels. (using
I'm plotting two semi-transparent ribbons together. Using the code below, without the scale_fill_manual portion,
So I semi-asked this in another thread about how to get .max and return
This is a semi-related question to question to the following question I just raised:
This is a interview Question which was asked and wanted to find an efficient

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.