2

我有一些表已在一个视图中连接在一起,当我想提取结果时我会执行该视图。我想将 where 子句应用于视图,以便过滤视图提供的结果,但是当我这样做时,我得到错误 The multi-part identifier could not be bound。

当从视图中获取 SQL 查询并使用我的 where 子句作为独立查询运行时,它运行良好,所以我在将 where 子句应用于我的视图时遇到了问题。

看法

SELECT     
   dbo.Assets.assetid, dbo.Assets.assetcommonname, dbo.Assets.assetcode,   
   dbo.Assets.assetserial, dbo.Assets.assetinternallocation, dbo.Assets.assetmodel, 
   dbo.Assets.assetmake, dbo.Assets.assetmac, dbo.Assets.assetnotes, 
   dbo.AssetTypes.typename, dbo.Locations.locationame, dbo.Customers.customername, 
   dbo.Routes.routename, dbo.Locations.customerid
FROM         
   dbo.Assets 
INNER JOIN
   dbo.AssetTypes ON dbo.Assets.assettype = dbo.AssetTypes.typeid 
INNER JOIN
   dbo.Locations ON dbo.Assets.assetlocation = dbo.Locations.locationid 
INNER JOIN
   dbo.Customers ON dbo.Locations.customerid = dbo.Customers.customerid 
INNER JOIN
   dbo.Routes ON dbo.Locations.locationroute = dbo.Routes.routeid

我如何使用 where 子句执行视图

select * from afViewassetlinked where (Locations.customerid = '1')

我做错了什么?

4

1 回答 1

4

改变

select * from afViewassetlinked where (Locations.customerid = '1')

select * from afViewassetlinked where (customerid = '1')

视图afViewassetlinked不是表Locations

于 2013-01-10T21:50:25.357 回答