Link to home
Start Free TrialLog in
Avatar of Clif
ClifFlag for United States of America

asked on

Odd Join Behavior

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?
ASKER CERTIFIED SOLUTION
Avatar of sshah254
sshah254

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Clif

ASKER

Yes, I made sure of this as well.
Avatar of Clif

ASKER

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

Thanks for leading me in the right direction.