[postgis-users] SELECT problem

Birgit Laggner birgit.laggner at vti.bund.de
Tue Sep 23 04:42:16 PDT 2008


Dear list,

probably, I'm just to unexperienced to see what I'm doing wrong, but 
that doesn't change that I need help :-)

I want to select a test dataset out of a bigger dataset (a). First part 
of the test dataset should be the first 100 geometries of (a) which have 
ids also occuring in a second dataset (b). Second part should be 100 
geometries of (a) whose ids don't match with ids of (b). This is my sql 
statement so far:

insert into bfn.nw_inv07_oc_rep_test
select
  a.gid,
  a.feldblocki,
  a.the_geom
 from bfn.nw_inv07_oc_rep a, bfn.nw_inv07_ol_test b
where a.gid=b.gid_inv07;
insert into bfn.nw_inv07_oc_rep_test
select
  a.gid,
  a.feldblocki,
  a.the_geom
from bfn.nw_inv07_oc_rep a
except
select
  a.gid,
  a.feldblocki,
  a.the_geom
from bfn.nw_inv07_oc_rep a, bfn.nw_inv07_ol_test b
where a.gid=b.gid_inv07
limit 100;

The first part of the insert works fine, but the result of the second 
insert looks strange for me: some rows double or even triple, while in 
the origin datasets, there are no duplicate rows.

Anybody who could explain what's happening during my query?

Thanks a lot,

Birgit.



More information about the postgis-users mailing list