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

x
?
Solved

Odd Join Behavior

Posted on 2011-10-26
3
Medium Priority
?
268 Views
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:
SELECT
    dbo.Invoice.Company,
    dbo.Invoice.Vendor,
    dbo.Invoice.JobNo,
    dbo.JobMaster.JobName
FROM
    dbo.Invoice
    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?
0
Comment
Question by:Clif
  • 2
3 Comments
 
LVL 9

Accepted Solution

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

SS
0
 
LVL 10

Author Comment

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

Author Closing Comment

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

Thanks for leading me in the right direction.
0

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