Fehler bei Abfrage mit Subquerry

Hallo,
ich habe eine Tabelle mit den folgenden Spalten:
id, datumzeit, von_pegel, bis_pegel, the_geom (s. auch CREATE …), die mit ca. 10 Datensätzen gefüllt ist

CREATE TABLE ueberschwemmungsflaechen
(
id serial NOT NULL,
datumzeit timestamp without time zone,
von_pegel real,
bis_pegel real,
the_geom geometry,
CONSTRAINT ueberschwemmungsflaechen_pkey PRIMARY KEY (id),
CONSTRAINT enforce_dims_the_geom CHECK (ndims(the_geom) = 2),
CONSTRAINT enforce_srid_the_geom CHECK (srid(the_geom) = 31467)
)
WITH (OIDS=TRUE);
ALTER TABLE ueberschwemmungsflaechen OWNER TO postgres;

Jetzt möchte ich eine Abfrage für eine Map-Datei machen, die wie folgt lautet:

$layer->set(data, “the_geom from (select the_geom from ueberschwemmungsflaechen where id = 1) As foo USING UNIQUE id using SRID=”.HW_SRID);

Ich krieg aber immer die folgende Meldung:

Warning: [MapServer Error]: prepare_database(): Error executing POSTGIS DECLARE (the actual query) statement: ‘DECLARE mycursor BINARY CURSOR FOR SELECT asbinary(force_collection(force_2d(the_geom)),‘NDR’),id::text from (select the_geom from ueberschwemmungsflaechen where id = 1) As foo WHERE the_geom && setSRID(‘BOX3D(2655443.86118437 5502443,2688791.10659338 5527443)’::BOX3D, 31467 )’ Postgresql reports the error as 'ERROR: column “id” does not exist LINE 1: …inary(force_collection(force_2d(the_geom)),‘NDR’),id::text f… ^ ’ More Help: Error with POSTGIS data variable. You specified ‘check your .map file’. Standard ways of specifiying are : (1) ‘geometry_column from geometry_table’ (2) ‘geometry_column from (sub query) as foo using unique column name using SRID=srid#’ Make sure you put in the ‘using unique column name’ and ‘using SRID=#’ clauses in. For more help, please see PostGIS : Documentation Mappostgis.c - versi in C:\ms4w\Apache\htdocs\webgis\hw_mapmanager.php on line 671


Es heißt: “…id does not exist…”. Aber die id ist doch da.
Kann mir bitte jmd. weiterhelfen?

Die “id” ist nur im Subselect vorhanden.

Und wo muss sie noch vorhanden sein?

OK, ich habs. Es muss lauten:

$layer->set(data, “the_geom from (select * from ueberschwemmungsflaechen where id = 1) As foo USING UNIQUE id using SRID=”.HW_SRID);