0

I have a problem in QGIS. I have an attribute table (no geographical information), which contains owners of parcels and an ID for every row.

Then I have a shapefile, which contains polygons and an attribute table which contains an ID (Fits with the owner information).

If I want to join these two parts, QGIS joins only one owner per parcel, even if there are 5.

How can I manage it, that finally there is a row in the attribute table of the shapefile, containing all owners and not only one?

2

There are a few concepts you have to know.

A join is a 1-to-1-relation: one parcel with one owner. If you do a join in QGIS then it will take the first corresponding owner and join it to the parcel

A relation is normally defined as 1 to many. This is your case. Here you have to define the relation through project > projectproperties > relations. Here you can set the relation-definitions. When you open the features dialogue, you will see every connected owner in an embedded table.

If you want to only have 1 row and all the owners in 1 field, you can use SQL or QGIS-expressions.

SQL

suppose you have following layers:

parcels:

enter image description here

owners:

enter image description here

Go to DB-manager > virtual layers > qgis layers. Open an sql-window and execute:

select parcel.*, group_concat(owner) as owners from parcel
left join owners on parcel.id = owners.parcel_id
group by owners.parcel_id

Load the results as a new layer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.