The function "Contains" allows to select all the objects of the layer " 1 " which are included in the layer " 2 "

Syntax : select ST_Contains(the_geom1,the_geom2) from myTable;

Remark : the_geom1 makes reference to the field "the_geom" of the layer 1. Also for the_geom2 which makes reference to the layer 2.

Example :

       - Goal : Select hydrographic network which are contains in the department called "Loire Atlantique".

       - Syntax : select a.* from TRONCON_HYDROGRAPHIQUE a,  dep_france_dom b where ST_Contains(b.the_geom, a.the_geom)  and b."NOM_DEPT"='LOIRE-ATLANTIQUE' ;

       - Result :


       - Remark : In this query we select all objects (a.*) of the layer "TRONCON_HYDROGRAPHIQUE" (alias a) which are contained in "dep_france_dom" (alias b). Be careful, "Contains" is a predicate which returns a boolean value (true if b contains the geometry of a).

Copyright - IRSTV - 2009 -