0

my database contains different objects like Polygons and Points. Each point is stored with a individual radius and index.

enter image description here

I retrieve all objects within a point radius with following sql query.

 declare @g geometry select @g = Geom from obj where ObjectIndex = 1
 declare @i float select @i = radius from obj where ObjectIndex = 1
 select * from obj WITH(index(idx_Spatial)) where
 Geom.STIntersects(@g.STBuffer(@i)) = 1 

How do i have to change the query in order to get all points within my Polygon object (Declared object)? I tried following query with no success. Rembember: Radius is different!

declare @g geometry select @g = Geom from obj where ObjectIndex = 2
select * from obj WITH(index(idx_Spatial)) where 
@g.STIntersects(Geom.STBuffer(radius)) = 1 

The query processor could not produce a query plan for a query with a spatial index hint

Jacks
  • 67
  • 5
  • Is this question tagged correctly? You've used two [tag:mysql] tags but this doesn't look (to me) like valid mysql code - specifically, I don't think mysql would support those two separate `declare`s with an assigning `select` between them. – Damien_The_Unbeliever Dec 27 '17 at 10:22
  • Also, "no success" is a rather vague term. What did you *expect* to happen? What *actually* happened (no results, wrong results, fewer than expected, more than expected, etc). Sample data and expected results would probably help a lot here. – Damien_The_Unbeliever Dec 27 '17 at 10:25
  • I expected to "get all points within my Polygon object". I got an error message "The query processor could not produce a query plan for a query with a spatial index hint". – Jacks Dec 27 '17 at 10:35

0 Answers0