[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Odd Join Behavior

Posted on 2011-10-26
Medium Priority
Last Modified: 2012-05-12
Unfortunately I cannot give you a sample, because a sample works.

Basically I have two tables that each contains several fields.  The tables were created by a third party application, and the data in them was inserted by that same app (basically no accidental mistyping of data).

The first table, we'll call Invoice, the second we'll call JobMaster

My query looks like this:
    LEFT OUTER JOIN dbo.JobMaster
        ON dbo.JobMaster.Company = dbo.Invoice.Company
        AND dbo.JobMaster.JobNo = dbo.Invoice.JobNo

Open in new window

For some reason, nothing from JobMaster is coming through (it's all NULL)

I know a record exists and can see the JobNo values in both tables.  I can copy the JobNo value returned from the query and put it in the WHERE clause of a separate query on JobMaster and the record will be returned.  I even tried LTRIM(RTRIM()) just in case there were some spurious spaces not apparent but that didn't work either.

Now I'll be the first to admit, I'm not a DBA or even a full fledged DB Developer, but this is a simple query of the type I've done dozens of times in the past.

What's up?
Question by:Clif
  • 2

Accepted Solution

sshah254 earned 2000 total points
ID: 37032790
Is the JobNo for the same company?  You have the join based on Company AND JobNo.

LVL 10

Author Comment

ID: 37033000
Yes, I made sure of this as well.
LVL 10

Author Closing Comment

ID: 37033108
I did, but did not try trimming them.  Once I did, the query worked.

Thanks for leading me in the right direction.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
How much do you know about the future of data centers? If you're like 50% of organizations, then it's probably not enough. Read on to get up to speed on this emerging field.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question