I'm using the following expression to join to layers and produce a virtual layer.

select * from table1 left join table2 on table1.field1=table2.field2

When I do it in Qgis, my virtual layer doesn't have the values from the joined table, whereas if I query exactly the same expression on pgadmin, it will return all values. Any ideas what's going on?

  • 1
    This seems to work as expected for me, as long as I don't include the layers as "embedded layers" in the "Create Virtual Layer" dialog, since the layers I'm joining are already in my project. If I do include them, I get zero results returned. Are you seeing results returned but without the columns from table2 present? Because I definitely see columns from my table2.
    – Spacedman
    Jan 6 at 11:22
  • My problem with embedded layers doesn't manifest if the layers are OGR layers, like shapefiles - it happens if they are memory layers which I'd created for testing. Which is interesting...
    – Spacedman
    Jan 6 at 13:07
  • Indeed. My layers are both Postgresql tables. If I don't embed the layers, the values are filled in the columns. It's a pity it won't update if I opt out of the embedding, but at least it works that way.
    – CAN84
    Jan 6 at 14:55
  • Forgot to mention that it only worked because I confgured a join between the two layers. So, nevermind doing the join through SQL, better just have a join configured.
    – CAN84
    Jan 6 at 15:21

Your Answer

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

Browse other questions tagged or ask your own question.