I'm trying to do something like this:

select *
from table_a
inner join table_b
  on table_b.fid = table_a.id
  and table_b.code =  @atlas_featureid

I have tried this using QGIS 2.18.16 and QGIS 3.0 but it doesn't seem to work. Am I missing something? Is there another approach to achieve this?

The alternative I could figure is to add a virtual layer without the last condition and symbolize just the ones that match the @atlas_featureid but this layer has about 100 times more features (≈ 300k) and it takes ages to work with it, it's not a viable solution.

  • I don't think this is possible. – HeikkiVesanto Mar 13 '18 at 11:15
  • What would happen if you don't have the composer open? You might have more luck with a python code updating the virtual layer query (which ends up like and table_b.code = 123 ) – JGH Mar 13 '18 at 11:18
  • @JGH The thing is that I want to generate several maps for every iteration and I have more layers that depend on these iterations. What you suggest would be to create my own atlas application right? – Albert Mar 13 '18 at 11:30
  • not an entire app, but small customizations done by code when the atlas page change – JGH Mar 13 '18 at 11:32
  • @JGH Thank you, I will investigate in this direction. The github link in this question: gis.stackexchange.com/questions/227203/… says: "QgsExpression functions are not supported in an SQL query. Addition of such a feature would be possible (since SQLite virtual table mechanism allows to add/overload functions)." So I guess it is not possible at the moment, it would make a nice feature though – Albert Mar 13 '18 at 12:05

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.