[Qgis-user] Help on creating a view

Francis Dupont Francis.X.Dupont at USherbrooke.ca
Thu May 29 07:40:22 PDT 2008


Hello!

I have two tables named myPtTable and myPolyTable on a PostGIS/PostgreSQL
8.3 server.  I want to join the two table based on a spatial query has
following:

SELECT a.gid, b.gid, a.level, b.name a.the_geom
FROM myPolyTable a, myPtTable b
WHERE st_contains(a.the_geom, b.the_geom)
ORDER BY a.level, a.gid;

The columns a.gid and b.gid are both primary key of type integer.  I read on
the forum that the way to join those tables and see them in QGIS (Io 0.10)
is done by using a view.  So I've done it but QGIS always give me the same
error that my view need a primary key.  The real primary key is the two gid
field because I have a N to N relationship between my two tables.  I saw on
the forum that it is a bug in QGIS that will be fixed someday.  What's the
solution?  To quick test if the view functionnality works in QGIS, I have
create the following query:

SELECT a.gid, a.level, a.the_geom FROM myPolyTable a

But in fact, my view still doesn't work in QGIS and a.gid is a PRIMARY KEY
with UNIQUE VALUE constraint.

I would like help from the community on that problem.  

Does the view functionnality work in QGIS?  If so, can I have a sample to
try it.  To join my two table, how can I create a primary key based on my
two fields in my view?

Thank you,

Francis
-- 
View this message in context: http://www.nabble.com/Help-on-creating-a-view-tp17536251p17536251.html
Sent from the qgis-user mailing list archive at Nabble.com.




More information about the Qgis-user mailing list