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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:13:49+00:00 2026-05-11T01:13:49+00:00

I have a main table that I must get data from. I have a

  • 0

I have a main table that I must get data from. I have a left outer join where the fields will match 40% of the time. And then I have another join where I need to match the data from table A with.

This is the SQL in pseudo code. This query won’t work.

— This is the part I want to do but doesn’t work. AND H.COL3 = A.STATE????

I am working with IBM DB2.

SELECT DISTINCT   APP_NO as app_no,   A.STATE as state   ...   ... Fields   ... FROM    TABLE_A A LEFT OUTER JOIN     TABLE_B HIST ON   HIST.COL1 = A.COL1 , TABLE_C B   LEFT OUTER JOIN   TABLE_D H   ON   H.COL2 = B.COL2 -- This is the part I want to do but doesn't work. AND   H.COL3 = A.STATE???? WHERE   A.BRANCH = 'Data' 
  • 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-11T01:13:50+00:00Added an answer on May 11, 2026 at 1:13 am

    I think you could re-write it like this (but I could be reading your statement wrong)

    FROM    TABLE_A A LEFT OUTER JOIN TABLE_B HIST ON       HIST.COL1 = A.COL1   LEFT OUTER JOIN TABLE_D H ON        H.COL3 = A.STATE   LEFT OUTER JOIN TABLE_C B ON H.COL2 = B.COL2 WHERE   A.BRANCH = 'Data' 

    Also, the IBM doco on this error states:

    An ON clause associated with a JOIN operator or in a MERGE statement is not valid. Explanation:

    Column references in an ON clause must only reference columns of tables that are in the scope of the ON clause.

    So I could be mistaken, it just looks like the erronous ON clause when outer joining ‘H.COL3 = A.STATE’ is out of scope of the On clause because the table A is not in that scope.

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

Sidebar

Ask A Question

Stats

  • Questions 97k
  • Answers 97k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If I understand your problem correctly, something along this line… May 11, 2026 at 7:28 pm
  • Editorial Team
    Editorial Team added an answer You don't need either break, but there's no harm in… May 11, 2026 at 7:28 pm
  • Editorial Team
    Editorial Team added an answer The file name and the class name have to be… May 11, 2026 at 7:28 pm

Related Questions

I have a UITableView that when scrolled to far bounces bag. This also means
I have some nested tables that I want to hide/show upon a click on
Let's say you have a table for branches in your organization. Some of them
I have a query that pulls up questions from one table and answers from

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.