[GIS] query / filter on attribute tables with external tables joined

attribute-joinsqgisquery

i tried to do some queries on joiend table fields …

i've got/found some answers concerning version 1.8 – which result in "use select + export to create a combined dataset"
so i just did some tests with Layer / query in qgis 2.2 valmiera and 2.3-master(build from 2014-05-02)) and ended up with the same problems:

while

  • "layer properties / style / column expression" tool is working fine
    based on "external" fields – even if i build complex expressions

  • and "table – select faetures by expressionn" doesn't seem to have any problems with where-clauses

"layer / query" returnes strange results with my demo-data; i.e.:

  • no problems with expressions unsing fields from the layer's attribute table
    but – as soon as i address "external" fields
  • but – as soon as i address "external" fields

    • the test feature returns an error:
      a simple query like "zsp_experimente_xls_WFL01_AREA" >= 1.52"
      (where 1.52 is valid value out of the sample-list) returns
      "OGR 3 error 1: type mismatch or improper type of arguments to >= operator"

      but "zsp_experimente_xls_WOHNFL01_AREA" LIKE "%" returns all records when testing the query ("the where clause teturned 1364 rows")

    • the confusing thing about that:
      the the sample tool privides correct results ! ! !
      ((which means to me that the select part of the statement works fine))

so finally i am still argueing that one of the essential benefits of the join-concept is, that you do not have to mix up geometry and attribute data -> which was a really great idea !!!!!!!

to select data by expression and export geometry and "added" additional data really undermines this concept by duplicating data !!!

Does anybody have any idea how to deal with that problem ?

Best Answer

Queries entered in layer properties | general | feature subset are passed to the GDAL/OGR data provider. Now, this data provider does not have any clue about joins which have been set up in QGIS. That's why it cannot access fields from joined layers.

You already know the work-around (saving and working with the new dataset or adding filters to the renderer instead of to the layer), so there is really not much more to say than that you can open a feature request. Also, if you can chose to work with databases tasks like this would be simpler.

Related Question