Forcing an ambiguous outer join

A

AccessKay

I tried to add another table to my query with a Left join and I receive a
message that my SQL contains ambiguous joins. It went on to say that I
needed to create a separate query and I think it was telling me to combine
the two. So I tried to do so but I received a syntax error about a missing
operator. I searched the previous posts and then added the parentheses.
Would you mind helping me put these two SQLs together? Thanks!!!

Qry1
SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblCostCat.TypeID, tblTransData.Trans_Date, tblTransData.TotHrs
FROM tblCostCat LEFT JOIN tblTransData ON tblCostCat.CostCatNm =
tblTransData.[cost category];

Qry2
SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblTransData.Trans_Date, tblTransData.TotHrs, tblCostCode.IndirectLabel
FROM tblCostCode LEFT JOIN tblTransData ON
tblCostCode.CostCode=tblTransData.[cost code];

My attempt to join them together:
SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblCostCat.TypeID, tblTransData.Trans_Date, tblTransData.TotHrs,
tblCostCode.IndirectLabel
FROM tblCostCat LEFT JOIN tblTransData ON (tblCostCat.CostCatNm =
tblTransData.[cost category]) AND tblCostCode LEFT JOIN tblTransData ON
(tblCostCode.CostCode=tblTransData.[cost code]);

This is where I received the missing operator error
 
K

Ken Snell

How about if you post the original query's SQL where you got the error
message about ambigous joins? Let's see if we can debug that query before we
come to any conclusions about whether you need to combine these two queries
or not.
 
A

AccessKay via AccessMonster.com

Thanks Ken for your reply. My original SQL is as follows:

SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category], tblCostCat.TypeID,
tblTransData.Trans_Date, tblTransData.TotHrs, tblCostCode.IndirectLabel
FROM tblCostCode LEFT JOIN (tblCostCat LEFT JOIN tblTransData ON tblCostCat.
CostCatNm = tblTransData.[cost category]) ON tblCostCode.CostCode =
tblTransData.[cost code];


Ken said:
How about if you post the original query's SQL where you got the error
message about ambigous joins? Let's see if we can debug that query before we
come to any conclusions about whether you need to combine these two queries
or not.
I tried to add another table to my query with a Left join and I receive a
message that my SQL contains ambiguous joins. It went on to say that I
[quoted text clipped - 28 lines]
This is where I received the missing operator error
 
K

Ken Snell

OK your query structure essentially is this:

tblCostCode ---> tblTransData <--- tblCostCat

This structure is unusual because the table of greatest interest (as noted
by your query's output fields) is on the right side of all the joins. But by
using the join setup, this tblTransData table may have no records that match
the other two tables' data keys.

Tell us in words what you want your query to select in terms of data
records. Let's get your query in the right shape.
--

Ken Snell
http://www.accessmvp.com/KDSnell/



AccessKay via AccessMonster.com said:
Thanks Ken for your reply. My original SQL is as follows:

SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblCostCat.TypeID,
tblTransData.Trans_Date, tblTransData.TotHrs, tblCostCode.IndirectLabel
FROM tblCostCode LEFT JOIN (tblCostCat LEFT JOIN tblTransData ON
tblCostCat.
CostCatNm = tblTransData.[cost category]) ON tblCostCode.CostCode =
tblTransData.[cost code];


Ken said:
How about if you post the original query's SQL where you got the error
message about ambigous joins? Let's see if we can debug that query before
we
come to any conclusions about whether you need to combine these two
queries
or not.
I tried to add another table to my query with a Left join and I receive a
message that my SQL contains ambiguous joins. It went on to say that I
[quoted text clipped - 28 lines]
This is where I received the missing operator error
 
A

AccessKay

I’m finding this hard to put into words without giving you my table structure.

tblTransData
ID-PK
Number
Empl
Cost Code (I want the Indirect Label from tblCostCode)
Cost Category (I want the TypeID from tblCostCat)
Hours

tblCostCat
CostCatNm-PK
TypeID

tblCostCode
CostCode-PK
Description
IndirectLabel

What do I need to do to get this to work. How should I change my structure.
Thanks again for your help.


Ken Snell said:
OK your query structure essentially is this:

tblCostCode ---> tblTransData <--- tblCostCat

This structure is unusual because the table of greatest interest (as noted
by your query's output fields) is on the right side of all the joins. But by
using the join setup, this tblTransData table may have no records that match
the other two tables' data keys.

Tell us in words what you want your query to select in terms of data
records. Let's get your query in the right shape.
--

Ken Snell
http://www.accessmvp.com/KDSnell/



AccessKay via AccessMonster.com said:
Thanks Ken for your reply. My original SQL is as follows:

SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblCostCat.TypeID,
tblTransData.Trans_Date, tblTransData.TotHrs, tblCostCode.IndirectLabel
FROM tblCostCode LEFT JOIN (tblCostCat LEFT JOIN tblTransData ON
tblCostCat.
CostCatNm = tblTransData.[cost category]) ON tblCostCode.CostCode =
tblTransData.[cost code];


Ken said:
How about if you post the original query's SQL where you got the error
message about ambigous joins? Let's see if we can debug that query before
we
come to any conclusions about whether you need to combine these two
queries
or not.

I tried to add another table to my query with a Left join and I receive a
message that my SQL contains ambiguous joins. It went on to say that I
[quoted text clipped - 28 lines]

This is where I received the missing operator error


.
 
J

John Spencer

As a guess you want a query that looks like

SELECT tblTransData.[ID-PK]
, tblTransData.Number
, tblTransData.Empl
, IndirectLabel
, TypeID
, Hours
FROM (tblTransData LEFT JOIN tblCostCat
ON tblTransData.[Cost Category] = tblCostCat.[CostCatNm-pk])
LEFT JOIN tblCostCode
I’m finding this hard to put into words without giving you my table structure.

tblTransData
ID-PK
Number
Empl
Cost Code (I want the Indirect Label from tblCostCode)
Cost Category (I want the TypeID from tblCostCat)
Hours

tblCostCat
CostCatNm-PK
TypeID

tblCostCode
CostCode-PK
Description
IndirectLabel

What do I need to do to get this to work. How should I change my structure.
Thanks again for your help.


Ken Snell said:
OK your query structure essentially is this:

tblCostCode ---> tblTransData <--- tblCostCat

This structure is unusual because the table of greatest interest (as noted
by your query's output fields) is on the right side of all the joins. But by
using the join setup, this tblTransData table may have no records that match
the other two tables' data keys.

Tell us in words what you want your query to select in terms of data
records. Let's get your query in the right shape.
--

Ken Snell
http://www.accessmvp.com/KDSnell/



AccessKay via AccessMonster.com said:
Thanks Ken for your reply. My original SQL is as follows:

SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblCostCat.TypeID,
tblTransData.Trans_Date, tblTransData.TotHrs, tblCostCode.IndirectLabel
FROM tblCostCode LEFT JOIN (tblCostCat LEFT JOIN tblTransData ON
tblCostCat.
CostCatNm = tblTransData.[cost category]) ON tblCostCode.CostCode =
tblTransData.[cost code];


Ken Snell wrote:
How about if you post the original query's SQL where you got the error
message about ambigous joins? Let's see if we can debug that query before
we
come to any conclusions about whether you need to combine these two
queries
or not.

I tried to add another table to my query with a Left join and I receive a
message that my SQL contains ambiguous joins. It went on to say that I
[quoted text clipped - 28 lines]
This is where I received the missing operator error

.
 
A

AccessKay

You’re good at guessing John! I put this in and it looked somewhat similar
to what I was doing but then I noticed that you switched the directions of
the joins (going FROM tblTransData TO tblCostCat and tblCostCode). If I just
use tblCostCat, it works when I place the join FROM tblCostCat TO
tblTransData. I also just tried it the other way to see if it works and it
does. I find that odd that it would work both ways. I’ll have to reprogram
my brain to do it this way from now on. I really appreciate your help with
this!

John Spencer said:
As a guess you want a query that looks like

SELECT tblTransData.[ID-PK]
, tblTransData.Number
, tblTransData.Empl
, IndirectLabel
, TypeID
, Hours
FROM (tblTransData LEFT JOIN tblCostCat
ON tblTransData.[Cost Category] = tblCostCat.[CostCatNm-pk])
LEFT JOIN tblCostCode
I’m finding this hard to put into words without giving you my table structure.

tblTransData
ID-PK
Number
Empl
Cost Code (I want the Indirect Label from tblCostCode)
Cost Category (I want the TypeID from tblCostCat)
Hours

tblCostCat
CostCatNm-PK
TypeID

tblCostCode
CostCode-PK
Description
IndirectLabel

What do I need to do to get this to work. How should I change my structure.
Thanks again for your help.


Ken Snell said:
OK your query structure essentially is this:

tblCostCode ---> tblTransData <--- tblCostCat

This structure is unusual because the table of greatest interest (as noted
by your query's output fields) is on the right side of all the joins. But by
using the join setup, this tblTransData table may have no records that match
the other two tables' data keys.

Tell us in words what you want your query to select in terms of data
records. Let's get your query in the right shape.
--

Ken Snell
http://www.accessmvp.com/KDSnell/



Thanks Ken for your reply. My original SQL is as follows:

SELECT tblTransData.number, tblTransData.Empl, tblTransData.[cost code],
tblTransData.[project alias], tblTransData.[cost category],
tblCostCat.TypeID,
tblTransData.Trans_Date, tblTransData.TotHrs, tblCostCode.IndirectLabel
FROM tblCostCode LEFT JOIN (tblCostCat LEFT JOIN tblTransData ON
tblCostCat.
CostCatNm = tblTransData.[cost category]) ON tblCostCode.CostCode =
tblTransData.[cost code];


Ken Snell wrote:
How about if you post the original query's SQL where you got the error
message about ambigous joins? Let's see if we can debug that query before
we
come to any conclusions about whether you need to combine these two
queries
or not.

I tried to add another table to my query with a Left join and I receive a
message that my SQL contains ambiguous joins. It went on to say that I
[quoted text clipped - 28 lines]
This is where I received the missing operator error
--



.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top