I am looking for a possibility to make a one-to-many table-join in QGIS.

I have a shapefile with postal codes and would like to join them with survey results (more than one). In other words, there is a specific postal code (shapefile) on one side and there are many survey participants on the other side.

postal **code1** ----- survey participant **1**
postal **code1** ----- survey participant **2**
postal **code1** ----- survey participant **3**
postal **code2** ----- survey participant **1**
postal **code2** ----- survey participant **2**
and so on ...

If I do a normal join (right click on Layer --> Properties --> Join) , I just get the first entry of the table with the postal codes.

I found out a way to do it ArcGIS with the tool "Make Query Table", but I´m looking for a possibility to do it in QGIS.

  • Welcome to gis.stackexchange! Please note that a good question on this site is expected to show some degree of research on your part, i.e. what you have tried and - if applicable - code so far. For more info, you can check our faq.
    – underdark
    Commented Jul 26, 2015 at 11:03

2 Answers 2


Depending on what exactly you want to do, you can use the relations functionality in QGIS.

See https://web.archive.org/web/20160313201132/http://blog.vitu.ch/10112013-1201/qgis-relations

This allows you show a table of related participants on the feature form of a zip code.

The QGIS 3.10 documentation of this feature is at https://docs.qgis.org/3.10/en/docs/user_manual/working_with_vector/attribute_table.html?#creating-one-or-many-to-many-relations

  • 2
    That a neat article thanks for sharing, can you expand this answer to include the parts that are relevant to this question? Sometimes links get broken and I think GIS.se tries to discourage link only answers.
    – SaultDon
    Commented Jun 23, 2016 at 16:53
  • 2
    The link to the blog post above is broken. Is there somewhere else that holds that post?
    – Johanna
    Commented Mar 8, 2017 at 4:23

You may use a processing scripts.

And here the one for an attributes cross-joining: https://github.com/kiselev-dv/QGIS-Processing/blob/master/scripts/spatial_cross_join_attributes.py

You may copy that script into {QGIS_HOME_DIR}/processing/scripts and use it via processing menu.

You have zip codes as an shape file, but I don't get in what form do you have survey data?

If they are points, import them as a new layer, and run spatial_cross_join_attributes script. It will asks you for two layers and name of results table. And in result table you'll get one row for each pair of zip and enclosed point.

zip1 point1
zip1 point2
zip2 point3
  • The survey data is a simple table (.csv) without any geometrys.
    – MTwain
    Commented Jul 29, 2015 at 13:03
  • I got a one zip code and many survey participants.
    – MTwain
    Commented Jul 29, 2015 at 13:11

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