join with GEOMETRY data type

  • I want to perform something like....

     

    SELECT * FROM a JOIN b ON a.geometryField  = b.geometryField

    OR

    SELECT * FROM a JOIN b ON a.geometryField.  STEquals(b.geometryField )

    OR

    SELECT geometryField FROM a

    WHERE geometryField  IN (SELECT geometryField FROM b )

     

    You get the gist.  None of the above work.  I know I need different syntax / operands but I'm really stuck.

     

    Any ideas?

     

    Thank you.

     

     

     

  • Ah I can get it working if I convert geometryField.ToString() - if there's a better way I'd be grateful for ideas, otherwise, thanks reading.

  • Did you try something like this:

    SELECT *

    FROM table1

    LEFT JOIN table2 ON ST_Equals(table1.the_geom, table2.the_geom);

    I searched google for -> tsql join on geometry column

    and found several results on gis.stackexchange.com such as this link https://gis.stackexchange.com/questions/167413/join-two-tables-completely-on-geometry-postgis which suggest you might want to use st_within instead of st_equals.  It might depend on what you are storing in the geometry column as to what type of comparison to use.  I have used .STContains to find if a point is in a polygon.

     

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply