Reputation: 3761
If I have the following line of code:
INNER JOIN #CompanyIdT t ON e.[companyId] = t.[Value] AND c.[CompanyId] = t.[Value]
Does this always join to the same companyId in the t table? So could e and c ever have a different CompanyId in 1 record?
Thanks
Upvotes: 0
Views: 110
Reputation: 107606
You've described a transitive relationship:
If e.CompanyId = t.Value and c.CompanyId = t.Value, then e.CompanyId = c.CompanyId.
Since that statement is always true, you should never have a different CompanyId
in any row in your query results. If you have duplicate Value
values in t, you could get multiple rows with the same CompanyId
.
Upvotes: 1
Reputation: 13641
No, e and c would never have a different value for companyID in a single record in the result set. They will always match t.Value, thus in your resultset it will always be the case that e.companyId = c.companyId = t.Value.
Upvotes: 2