Hallo ich habe ein kleines Problem mit UNION:
ich habe eine uhrsprüngliche sql abfrage, die mir die nächsten punkte in meinem umfeld zurück gibt (diese funktioniert auch ohne probleme):
ELECT name, type, ST_Distance(ST_SetSRID(st_makepoint($newcenter1,$newcenter2),4326), ST_SetSRID(the_geom,4326),true), ST_Y(ST_SetSRID(the_geom,4326)), ST_X(ST_SetSRID(the_geom,4326))
from points
where st_dwithin(st_makepoint($newcenter1,$newcenter2), the_geom, $newdistance, true) AND name IS NOT NULL AND type = '$newproxType'
ORDER BY ST_Distance(ST_SetSRID(st_makepoint($newcenter1, $newcenter2),4326), ST_SetSRID(the_geom,4326)), name
LIMIT 50
nun füge ich mit UNION eine weitere abfrage für ein zweites schema hinzu und order dann am ende:
SELECT *
FROM (SELECT name, type, ST_Distance(ST_SetSRID(st_makepoint($newcenter1,$newcenter2),4326), ST_SetSRID(the_geom,4326),true), ST_Y(ST_SetSRID(the_geom,4326)), ST_X(ST_SetSRID(the_geom,4326))
from points
where st_dwithin(st_makepoint($newcenter1,$newcenter2), the_geom, $newdistance, true) AND name IS NOT NULL AND type = '$newproxType'
UNION
SELECT name, type, ST_Distance(ST_SetSRID(st_makepoint($newcenter1,$newcenter2),4326), ST_SetSRID(the_geom,4326),true), ST_Y(ST_SetSRID(the_geom,4326)), ST_X(ST_SetSRID(the_geom,4326))
from userfeatures.points
where st_dwithin(ST_SetSRID(st_makepoint($newcenter1,$newcenter2),4326), ST_SetSRID(the_geom,4326), $newdistance, true) AND name IS NOT NULL AND type = '$newproxType' ) t
ORDER BY ST_Distance(ST_SetSRID(st_makepoint($newcenter1, $newcenter2),4326), ST_SetSRID(the_geom,4326)), name
LIMIT 150
jedoch bekomm ich dann immer diese Fehlermeldung(obwohl the_geom eigentlich existiert und es auch beim suchen eines schemas funktioniert…):
Warning: pg_query(): Query failed: ERROR: column "the_geom" does not exist LINE 10: ..._makepoint(8.178479, 53.139927),4326), ST_SetSRID(the_geom,4... ^ in /Applications/XAMPP/xamppfiles/htdocs/prototype1/proximitySearch.php on line 43
Abfrage fehlgeschlagen: ERROR: column "the_geom" does not exist LINE 10: ..._makepoint(8.178479, 53.139927),4326), ST_SetSRID(the_geom,4... ^
hat jemand eine idee was ich falsch mache?
Vielen Dank im Vorraus
Michael Hecht