SQL Server 无法在两列之间使用AND逻辑运算符

pftdvrlh  于 2023-01-08  发布在  其他
关注(0)|答案(1)|浏览(117)

这是我得到的以下错误:
错误:在上下文中指定了非布尔类型的表达式,而上下文中的“and”附近需要条件。

select p.BusinessEntityID, p.FirstName, p.LastName, bea.BusinessEntityID, bea.AddressID
from Person.Person as p
left join
Person.BusinessEntityAddress as bea on 
p.BusinessEntityID = bea.BusinessEntityID
where bea.BusinessEntityID and bea.AddressID is NOT NULL
deikduxw

deikduxw1#

此处表达式不清楚.你必须这样写

where bea.BusinessEntityID Is Not NuLL and bea.AddressID is NOT NULL

或者像这样

where bea.AddressID is NOT NULL

bea.BusinessEntityID检查了加入,你不需要它。删除更好

相关问题