This question already has an answer here:

I have an Attribute Table named 'data.shp' and a Vector Layer 'pop.shp'.

The 'data.shp' has the following fields "ID", "value1", "value2"

The 'pop.shp' has the "ID" field (same with the 'data.shp')

I want to update 'pop.shp' and add the fields "value1", "value2" from 'data.shp' where "ID" (from 'data.shp') is equal to "ID" (from 'pop.shp').

How could I do that in QGIS?

marked as duplicate by underdark qgis Feb 21 at 17:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    Have you checked this tutorial Performing Table Joins? Start from Step #12, inclusive. – Taras Feb 21 at 14:27
  • 2
  • @Taras it seems sql tag was removed. That tag is essential to distinguish Nat's question from the linked one. Thanks! – Kazuhito Feb 21 at 14:54
  • @Kazuhito, shall I place it back? However, I did not find out anything related to sql in the gist of the question itself, is not it? Can you clarify this for me, please? – Taras Feb 21 at 15:04
  • @Kazuhito I'm not sure the sql tag is that relevant even to the linked questions. The joins can be done without it. – Gabriel C. Feb 21 at 15:05

QGIS has built-in table join capabilities. If you want to add fields from a table (data.shp) into another layer (pop.shp), then go this way:

  • Right click on pop.shp -> Properties -> Joins -> "+"
  • Choose relevant layer and key field for the join
  • Check which fields you want to add
  • Click OK

The attribute table from your pop.shp layer should now include the data you need. To make this permanent, save the layer as a new file.

enter image description here


You can perform it with a Virtual Layer from Layer > Add Layer > Add/Edit Virtual Layer

SELECT pop.*, data.value1, data.value2
FROM pop
LEFT JOIN data ON pop.id = data.id


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