QGIS 3.22.7 – How to Perform an Inner Join

attribute-joinsqgis

I have to join some attributes of two layers in QGIS (3.22.7). Therefore, I am required to use inner join. When I go to the layer properties of the first layer and join the two layers/tables with a common attribute, then the resultant table had null values which should not be present. For that, I have filtered the null values of that column of the second layer before applying the join. Still, the final table has the null values. Hence, I think the join I am doing is the left join and inner join could be a solution to avoid null values in that column. So, how can I apply inner join in QGIS 3.22.7?

I have to use the following SQL query

SELECT A.ATT1, A.ATT2, B.BTT1
FROM LAYER1 B
INNER JOIN LAYER2 A
ON A.ATT1 = B.BTT2
WHERE B.BTT2 NOT LIKE 'NULL' and B.BTT2 LIKE 'ABC'

I have tried to filter the NULL values with the following command
"BTT2" NOT LIKE 'NULL' and "BTT2" LIKE 'ABC'
The output is
enter image description here

Best Answer

You can create a virtual layer with the query:

select t1.*
from layername1 t1
inner join layername2 t2
on t1.fieldx = t2.fieldy