Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何在Sql 2008中执行此空间查询?_Sql Server_Sql Server 2008_Subquery_Spatial - Fatal编程技术网

Sql server 如何在Sql 2008中执行此空间查询?

Sql server 如何在Sql 2008中执行此空间查询?,sql-server,sql-server-2008,subquery,spatial,Sql Server,Sql Server 2008,Subquery,Spatial,我试图在sql 2008->中对给定的POI列表(兴趣点,long/latGEOGRAPHYdata)进行空间查询,它们存在于哪个邮政编码中(multipolygonGEOGRAPHYdata) 这是我尝试过的查询,但在语法上不正确:- SELECT PostCodeId, ShapeFile FROM Postcodes a WHERE a.ShapeFile.STIntersects( SELECT PointOfInterest FROM PointOfInterests

我试图在sql 2008->中对给定的POI列表(兴趣点,long/lat
GEOGRAPHY
data)进行空间查询,它们存在于哪个邮政编码中(multipolygon
GEOGRAPHY
data)

这是我尝试过的查询,但在语法上不正确:-

SELECT PostCodeId, ShapeFile
FROM Postcodes a
WHERE a.ShapeFile.STIntersects(
    SELECT PointOfInterest
    FROM PointOfInterests
    WHERE PointOfInterestId IN (SELECT Item from dbo.fnSplit(@PoiIdList, ','))
这意味着我要通过一个考试。那不是问题。。这是我在
STIntersects
中的子查询。那是无效的

所以。。各位有什么建议吗?

怎么样:

SELECT a.PostCodeId, a.ShapeFile
FROM (SELECT Item from dbo.fnSplit(@PoiIdList, ',')) AS POI_IDs
INNER JOIN PointOfInterests
    ON PointOfInterests.PointOfInterestId = POI_IDs.Item
INNER JOIN Postcodes a
    ON a.ShapeFile.STIntersects(PointOfInterests.PointOfInterest) = 1

感谢堆:)我不知道你可以加入两个表在一段时间!我唯一的问题是性能以及最好的方法是什么。现在,这超出了我的理解范围(SpatialSQL对我来说是全新的)