In QGIS, it is common to associate data from an external table with a geographic layer. For example, you may have a layer of municipalities and a CSV file containing demographic statistics.
To combine this information, QGIS allows you to perform a table join. This operation links two tables using a common field.
In this article, we will see how to join a table in QGIS and how to avoid the most common mistakes.
1. The Principle of a Table Join
A table join allows you to add fields from an external table to the attribute table of a layer.
Example:
| municipality_code | name | population |
|---|---|---|
| 001 | Municipality A | 1200 |
| 002 | Municipality B | 850 |
If the geographic layer also contains a field named municipality_code, QGIS can use this field to associate the data.
2. Preparing the Tables
Before performing the join, it is important to verify that:
- a common field exists in both tables
- the values match exactly
- the field type is the same (text or integer).
Example:
| Geographic layer | CSV table |
|---|---|
| code | code |
3. Adding the Table in QGIS
If the table is stored in a CSV file:
Layer menu → Add Layer → Add Delimited Text Layer
The table will then appear in the list of layers.
4. Performing the Join
In QGIS:
- Right-click on the geographic layer
- Select Properties
- Open the Joins tab
- Click Add Join

In the dialog box:
- choose the table to join
- select the common field
- select the corresponding field in the layer
Then click OK.
The new fields will appear in the attribute table.
5. Checking the Join
After performing the join:
- open the attribute table
- verify that the new fields are present
- check that the values match correctly.
If some fields are empty, it usually means that the matching values were not found.
6. Table Join vs Spatial Join in QGIS
In QGIS, there are two types of joins:
- table joins
- spatial joins
These two operations allow you to associate data, but their principles are different.
Table Join
A table join uses a common field between two tables.
Example:
| municipality_code | name |
|---|---|
| 001 | Municipality A |
| 002 | Municipality B |
And a statistical table:
| municipality_code | population |
|---|---|
| 001 | 1200 |
| 002 | 850 |
The join is performed using the municipality_code field.
Spatial Join
A spatial join uses the geographic position of objects.
Example:
- a layer of municipalities
- a layer of points representing schools
You can then associate with each municipality the number of schools located within its boundaries.
In QGIS:
Vector → Data Management Tools → Join attributes by location

The spatial relationship may be:
- intersects
- contains
- within.
Comparison
| Table join | Spatial join |
|---|---|
| uses a common field | uses geographic position |
| links two tables | links two geographic layers |
| very fast | more computationally intensive |
Key Takeaways
- Table join → based on a common field
- Spatial join → based on the geometry of the objects
Both operations are very useful for enriching geographic data in QGIS.
FAQ: Common Errors
Fields remain empty
This often happens when:
- the values do not match exactly
- the field types are different (text vs integer).
The join does not work
Check:
- spelling of the values
- spaces in the fields
- data types.
Common causes include:
- different values in the fields
- hidden spaces or characters
- different field types.
The join disappears after restarting QGIS
By default, a join is temporary.
To keep the joined data, export the layer:
Right-click the layer → Export → Save Features As…

Three Reasons Why a Join Does Not Work in QGIS
Checking values using unique values
When a join does not work, the problem usually comes from the field used to link the tables.
Possible issues include:
- different values
- invisible spaces
- uppercase/lowercase differences
- different field types.
A simple method is to check the unique values.
In QGIS:
- open the attribute table
- open the statistics panel or expression tool
- display the unique values of the field used for the join
This allows you to verify whether the values match between the two tables.
Example of a Common Problem
In a layer:
001
002
003
In the CSV table:
1
2
3
The join will not work because the values are not identical.
Another Common Problem: Spaces
In some CSV files, spaces may appear.
Example:
001
002
003
But the actual values may be:
001␠
002␠
003␠
These spaces prevent matching.
Solution: Clean the Fields
In QGIS, you can use an expression to remove spaces:
trim("field")
This allows you to clean the values before performing the join.
Key Point
If a join does not work in QGIS, check that:
- the values are identical
- there are no spaces
- the field types are the same.
In most cases, the problem comes from one of these elements.
Conclusion
Table joins are a very useful operation in QGIS for enriching a geographic layer with data from an external table.
By ensuring that a common field exists and that the values match correctly, it becomes very easy to associate statistical information with spatial data.