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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:53:55+00:00 2026-06-04T08:53:55+00:00

I am having an issue joining 3 tables where the data i need is

  • 0

I am having an issue joining 3 tables where the data i need is one of two tables, but not both.

So lets say we have table ‘customers’ with columns ‘id’, ‘city’, ‘state’, and 2 data tables data_a and data_b with column ‘id’ and the data i want.

right now i have a statement similar to the below.

SELECT cust.id, cust.city, cust.state, a.info as infoa, b.info as infob
  FROM customers cust
  INNER JOIN data_a a 
    ON cust.id = a.id
  INNER JOIN data_b b
    ON cust.id = b.id
  WHERE cust.city = 'mytown';

This takes forever to run, and I have not gotten any responses from the query since i will kill it before it finishes (if it will ever actually finish).

If I remove the second data table the statement works fine, only when I added it do i run into issues. All the id columns are indexed, as well as the city column.

Or am I better off creating a temp table and doing 2 joins, inserting those into the temp and reading from the temp?

edit: fixed the typo

If i do left joins the query sits at executing, presumably indefinitely. When using Inner Joins I will get a empty set.

  • 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-04T08:53:57+00:00Added an answer on June 4, 2026 at 8:53 am

    If the join will be on one table, but not both, then you need LEFT JOIN:

    SELECT cust.id, cust.city, cust.state, a.info as infoa, b.info as infob
      FROM customers cust
      LEFT JOIN data_a a 
        ON a.id = cust.id
      LEFT JOIN data_b b
        ON b.id = cust.id
      WHERE cust.city = 'mytown';
    

    Ensure that you have the following indexes:

    cust: ('city')
    data_a: ('id')
    data_b: ('id')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
Having an issue with traversing in jQuery.. hopfully an easy one..but I'm banging my
I am having an issue with the filtering my table F0005 properly. I have
Having an issue with one my scripts. The animation keeps queueing up. I have
I have a primefaces dataList within a primefaces dataGrid but I'm having issue mapping
I am having a issue finding a fast way of joining the tables looking
Having another issue, and this one is BAFFLING! Here we go. We have a
Experts, I'm having issue when sending emails out. Currently, I have a feedback form
I have two views one of them is in landscape and other in portrait.
I am having issue when sending data from Service to Activity through Notification ,

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.