Join between Postgis table and Postgresql table

Paul Ramsey pramsey at REFRACTIONS.NET
Wed Nov 9 14:34:58 EST 2005


No, no, do it on the fly, using the "arbitrary SQL" feature of the  
Mapserver PostGIS connector:

DATA "the_geom from (SELECT g.gid, g.the_geom, a.name, a.description  
FROM geometries g, attributes a WHERE g.id = a.id) using SRID=4326  
using unique gid"

Note you have to have a geometry and unique id in your output result,  
and you have to specify the output SRID.  Any SQL is valid in between  
the (), just make sure you're always outputting a geometry and id.

Paulo

On Nov 9, 2005, at 1:53 AM, Frans Knibbe wrote:

> Hello Carlo,
>
> If your data do not change much you could join the two tables in  
> postgreSQL to make a new table which can be used by MapServer. This  
> you will probably have better performance as well.
>
> Regards,
>
> Frans
>
> Carlo Calvino wrote:
>
>> Hello all of you,
>> I built a spatial database with PostgreSql/PostGis, and imported a
>> shapefile (cities.shp) inside it. So I have a postgresql database  
>> with 2
>> tables, one for the geographic data and the other for alphanumeric  
>> data.
>> I was able to publish the vector data by MapServer, and I was also  
>> able to
>> query it correctly. But...what about querying the vector layer using
>> information from the second table? I need joining the two tables.  
>> As far
>> as I know, it is only possible a join between Postgis and a dbf  
>> file, not
>> a DBMS. So there are any suggestions?
>>
>>
>>



More information about the mapserver-users mailing list