我想编写一个SQL脚本,它将返回EmployeeMaster表中包含LastName,City,State和Country列的所有Employees。
这是我试图执行但它显示错误。
SELECT dbo.EmployeeMaster.LastName, dbo.EmployeeDetails.City, State, Country
From dbo.EmployeeMaster
LEFT JOIN EmployeeDetails
ON dbo.EmployeeMaster.ID=dbo.EmployeeDetails.EmployeeID
ORDER BY dbo.EmployeeMaster.LastName
答案 0 :(得分:0)
我认为你在左边缺少dbo prefixe加入no?由于您是在ON
,ORDER
和SELECT
SELECT dbo.EmployeeMaster.LastName, dbo.EmployeeDetails.City, State, Country
From dbo.EmployeeMaster
LEFT JOIN dbo.EmployeeDetails ON dbo.EmployeeMaster.ID=dbo.EmployeeDetails.EmployeeID
ORDER BY dbo.EmployeeMaster.LastName
不确定哪个表状态& ountry来自,希望他们不在两个表中,否则你需要添加他们的表别名。