Search code examples
postgresqlpostgismapserver

Multiple rows in subquery


I am trying to create a context of exclusion zone in my layer.

I am trying the following Map File/SQL combo

DATA "geom FROM public.data"
FILTER "layer = %layer_id% AND ST_CONTAINS(ALL(SELECT the_geom FROM public.exclusion_zone WHERE layer = %layer_id%), geom) != true"

Obviously this breaks when there are more then 1 exclusion zone, so how do I do this?

I've tried storedProc's already only to be told MapServer can't find it's SRID as it doesn't appear in the geometry table

The error I am receiving is thus

Query error. Error (ERROR: more than one row returned by a subquery used as an expression ) executing query

Solution

  • Try this:

    DATA "geom FROM public.data"
    FILTER "
        layer = %layer_id% and
        not exists
        (
            SELECT *
            FROM public.exclusion_zone
            WHERE layer = %layer_id% and ST_CONTAINS(the_geom, geom)
        )