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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:48:21+00:00 2026-06-12T02:48:21+00:00

OK, so I’ve found questions that cover how to do this with only two

  • 0

OK, so I’ve found questions that cover how to do this with only two tables, tons of questions that explain how to do this if the ID does NOT exist in other tables, but not a solution to this query.

Basically, I have one table of wine vintages.

I then have four other tables that contain different types of content that is tied to a specific vintage (i.e. videos, blogs etc.)

I basically need to be able to pull a list of vintages that are in use i.e. where the vintage ID is used in one or more of the four content tables.

The closest I can get is this:

SELECT DISTINCT vintage_id FROM `pr_video_vintage`
INNER JOIN pr_video ON pr_video.fk_vintage_id = pr_video_vintage.vintage_id
INNER JOIN pr_reports ON pr_reports.fk_vintage_id = pr_video_vintage.vintage_id
INNER JOIN pr_reports_notes ON pr_reports_notes.fk_vintage_id = pr_video_vintage.vintage_id
INNER JOIN pr_blog_entries ON pr_blog_entries.fk_vintage_id = pr_video_vintage.vintage_id
ORDER BY `pr_video_vintage`.`vintage_id` ASC

But this (understandably I guess) only returns IDs that exist in ALL of the tables.

What I need is some form of ‘OR’ JOIN, but can’t find any information out about how to go about doing this.

tips? 🙂

  • 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-12T02:48:22+00:00Added an answer on June 12, 2026 at 2:48 am

    Try this:

    SELECT  distinct vintage_id FROM `pr_video_vintage`
    where exists(select 1 from pr_video where pr_video.fk_vintage_id = pr_video_vintage.vintage_id)
       or exists(select 1 from pr_reports where pr_reports.fk_vintage_id = pr_video_vintage.vintage_id)
       or exists(select 1 from pr_reports_notes where pr_reports_notes.fk_vintage_id = pr_video_vintage.vintage_id)
       or exists(select 1 from pr_blog_entries where pr_blog_entries.fk_vintage_id = pr_video_vintage.vintage_id)
    

    or

        SELECT  distinct vintage_id FROM `pr_video_vintage`
    where pr_video_vintage.vintage_id in (select pr_video.fk_vintage_id from pr_video)
       or pr_video_vintage.vintage_id in (select pr_reports.fk_vintage_id from pr_reports)
       or pr_video_vintage.vintage_id in (select pr_reports_notes.fk_vintage_id from pr_reports_notes)
       or pr_video_vintage.vintage_id in (select pr_blog_entries.fk_vintage_id from pr_blog_entries)
    

    or

    SELECT  distinct vintage_id FROM `pr_video_vintage`
    where pr_video_vintage.vintage_id in (
       select pr_video.fk_vintage_id from pr_video
       union
       select pr_reports.fk_vintage_id from pr_reports
       union
       select pr_reports_notes.fk_vintage_id from pr_reports_notes
       union
       select pr_blog_entries.fk_vintage_id from pr_blog_entries)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know there's a lot of other questions out there that deal with this
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.