我是一名具有一定SQL经验的分析师,但我还没有加入超过2个表。我正在尝试加入这3个表,我无法将表绑定在一起并取得成功。我做错了什么?
Use Db3
Select Persons.DateOfBirth
, Persons.DisabilityCode
, Persons.Ethnicity
, Persons.Gender
, Persons.Country
, Persons.MaritalStatus
, Persons.Suffix
, Persons.LastName
, Persons.FirstName
, Persons.MiddleName
, Persons.CommonOrPreferredName
, Persons.Credentials
, Persons.IsActive
, Persons.MilitaryStatus
, Jobs.Id
, Jobs.AdjustedDateOfHire
, Jobs.DateOfHire
, Jobs.CompanyOwnershipStatus
, Jobs.LeaveDate
, Jobs.TerminationDate
, OrganizationalAssociations.Id
, OrganizationalAssociations.EmployeeNumber
, OrganizationalAssociations.SourceSystemEmployeeId
, OrganizationalAssociations.EmploymentType
From Persons Person
JOIN Persons ON Persons.Id = Jobs.Id
JOIN Jobs ON Jobs.Id = Persons.Id
JOIN OrganizationalAssociations ON OrganizationalAssociations.Id = Persons.Id
错误消息:无法绑定Jobs.Id
答案 0 :(得分:0)
您不需要使用Person
表格JOIN Persons ON Persons.Id = Jobs.Id
加入。在使用Person表
Use Db3
Select Persons.DateOfBirth
, p.DisabilityCode
, p.Ethnicity
, p.Gender
, p.Country
, p.MaritalStatus
, p.Suffix
, p.LastName
, p.FirstName
, p.MiddleName
, p.CommonOrPreferredName
, p.Credentials
, p.IsActive
, p.MilitaryStatus
, j.Id
, j.AdjustedDateOfHire
, j.DateOfHire
, j.CompanyOwnershipStatus
, j.LeaveDate
, j.TerminationDate
, o.Id
, o.EmployeeNumber
, o.SourceSystemEmployeeId
, o.EmploymentType
From Persons p
JOIN Jobs j ON j.Id = p.Id
JOIN OrganizationalAssociations o ON o.Id = p.Id
答案 1 :(得分:0)
我认为你真的不需要第一次加入.. 删除行JOIN Persons ON Persons.Id = Jobs.Id并尝试。你应该很好。