[postgis-users] Advanced query problem

Bill Binko bill at binko.net
Mon Feb 27 06:19:06 PST 2006


I believe a simpler answer is: the field (oid) that you're telling 
Mapserver is unique is not unique in your query. Mapserver does not like 
that.

You need to give mapserver a unique key for your dataset. In your case, 
you may get away with using the oid from the second (many side) table: 
just change your query to return table2.oid instead of table1.oid.

Bill


Robert Burgholzer wrote:

> It seems that you are doing a join in Postgis, which does not differ 
> from any other regular criteria join in SQL, as Bill points out, you 
> will get as many copies of the geometry as you have matching record in 
> your 2^nd table. What I believe you are hoping for is a “crosstab” 
> type of join perhaps, or, more appropriately a custom way of handling 
> your query results so that you get the information you want when you 
> click on your map. In that case, your best bet is to specify your 
> mapserver layer with just a simple query line, i.e., “the_geom from 
> table1”, and then manage the join in the routine that handles the 
> query results. For help on how to do that, the mapserver forum would 
> probably be the best bet.
>
> Good lluck,
>
> rob
>
> ------------------------------------------------------------------------
>
> *From:* postgis-users-bounces at postgis.refractions.net 
> [mailto:postgis-users-bounces at postgis.refractions.net] *On Behalf Of 
> *Krishnaa Sridharan
> *Sent:* Sunday, February 26, 2006 6:02 PM
> *To:* postgis-users at postgis.refractions.net
> *Subject:* Re: [postgis-users] Advanced query problem
>
> Bill thanks a lot for your reply. I did change the left join to inner 
> join. But the problem I am having is while trying to connect two 
> tables with one to many relationship. What mapeserver is doing is this,
>
> Table 1 ( spatial table ) Table 2 ( postgre table)
>
> These are unique numbers Table to has multiple values for the same 
> unique number in table 1.
>
> 101 101 John
>
> 102 101 Tom
>
> 103 102 Mark
>
> If I run the query my out put looks like this
>
> 101 John
>
> 101 **John**
>
> 102 Mark
>
> Mapserver is not returning the second value from table 2 instead its 
> returning the same thing again. I am sorry if I have any basic things 
> wrong, I am really new to this and any bit of info would help thanks.
>
> Kris
>
>------------------------------------------------------------------------
>
>_______________________________________________
>postgis-users mailing list
>postgis-users at postgis.refractions.net
>http://postgis.refractions.net/mailman/listinfo/postgis-users
>  
>




More information about the postgis-users mailing list