Feature request #8141

query / filter on attribute tables with external tables joined

Added by robert kalasek over 11 years ago. Updated about 7 years ago.

Status:Open
Priority:Normal
Assignee:-
Category:Unknown
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:16969

Description

concerns version 1.8 and 1.9

i have been searching various blogs and use groups and found that issue addressed allready there some times.
problem is that filter (v. 1.9) query(v1.8) entry disappears from context menue as soon as i join an external table. consequently properties / general / subset / query builder is greyed then ...

... unsing arcXY for at least 15 years i know for shure that it is really useful to be able defining a subset via query on joined data. to be honest i was really confused and kept searching the interface for quite a while.

the most often suggested workaround to select (manually or via advanced search) the data and then export it seems a little uggly to me - since it ends in multiplying your data which usually ends up in chaos. beeng able to join and to work with joined information without having to create new data was one of the key features for efficient data handling.
and (!) the advanced serach option works fine with joined data !
... so i would assume that it couldn't be a big issue to implement this useful feature.
i would really (!) appreciate !

best regards robert

History

#1 Updated by Nathan Woodrow over 11 years ago

The main thing to be aware of here is the Set Filter/Query option is setting a filter at the provider level, in most cases by appending a WHERE clause. When you have joined data the provider itself doesn't know about the extra fields because they don't exist there.

Example

Layer1 (Shapefile)
Layer2 (MS SQL layer)

If I join layer1 onto layer2 the layer1 data provider which is ogr doesn't know anything about the layer2 fields coming from the mssql driver. The join is done at a layer level, not at the provider level.

The advanced search is working also at a layer level so it knows about the join fields and just uses QGIS methods to search for the data.

The new API should allow use to add new layer based filtering which would take into account joined fields.

#2 Updated by robert kalasek over 10 years ago

still the same problem in qgis 2.2 valmiera and 2.3-master(build from 2014-05-02))

had some tests with Layer / query ... and was even more confused afterwards.
(can provide demo-data if needed/helpful)

anyway - i can't really understand nathan's answer because
  • layer properties / style / column expression tool is working fine based on fields - even if i build complex expressions
  • table - select faetures by expressen doesn't seem to have any problems with where-clauses
while layer / query returned 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
  • the sample tool privides correct results ! ! !
which means to me that the select part of the statement works fine)
  • 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")

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 !!!!!!!
select by expression + export really undermines this concept by dublicating data !!!
best regards robert

#3 Updated by Giovanni Manghi over 7 years ago

  • Easy fix? set to No

#4 Updated by Jürgen Fischer about 7 years ago

  • Category set to Unknown

Also available in: Atom PDF