多部分标识符无法绑定

时间:2015-06-03 16:32:39

标签: sql sql-server

我有三个SQL表,如下所示:

Policy
    PolicyId
    ClientId

ClientLocations
    ClientLocationId-int type
    ClientId-FK int
    LocCountryID Int
    PrimaryLocation bool

Country
    CountryID
    CountryName

在ClientLocations中,我可以为一个客户端ID提供多个值:

ClientLocationId,ClientId,LocCountryID,PrimaryLocation 
1111,2435,8888,0
1112,2435,8888,1

现在我正在编写一个存储过程,如下所示,从国家/地区表中获取特定政策的国家/地区名称。

DECLARE @ncountryID int
SELECT *
FROM Policy AS p
INNER JOIN ClientLocations AS cl ON p.ClientId = cl.ClientId
INNER JOIN Country AS co ON co.CountryID = cl.LocCountryID
WHERE cl.LocCountryID = @ncountryID 

在执行此操作时,我收到错误为multi part identifier Cl.LocCountryID could not be bound.

我做错了什么?

0 个答案:

没有答案