[Qgis-user] Query a joined layer

James Stott James.Stott at npaconsult.co.uk
Fri Nov 4 05:42:51 PDT 2011


Thanks for the replies. It's interesting to know how all of this stuff
works internally Nathan. 

 

It works if I use the query builder from the attribute table, and will
select the features that match the query (and highlight them on the
map/attribute table). 

 

If I use rule based styling I can also select things by attribute and
style by attribute.

 

If I use the right click menu on the layer with the join and select
Query... (or Layer > Query... from the menu) this is where it will not
return any results. I would like to query in this way as I would like to
select all of the features that relate to a certain project, and to do
this using rule based styling would take quite some time.

 

I won't be able to send the actual data as it belongs to our clients.
But if necessary I can mock some data up and post it.

 

From: Nathan Woodrow [mailto:madmanwoo at gmail.com] 
Sent: 04 November 2011 12:38
To: James Stott
Cc: qgis-user at lists.osgeo.org; qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-user] Query a joined layer

 

Hey James,

 

I think the problem might be that the query builder, when you press ok,
is setting the the layer subset via
QgsDataProvider::setSubsetString(string).  How setSubSetString works is
up to the provider.  In your case the provider, that you joined to,
doesn't know anything about the other fields or how to filter based on
them so it just returns nothing.

 

QGIS itself doesn't have a SQL engine in it's own right all most
everything with querying, except for the basic stuff, is passed to the
provider.   I have had a chat to a few of the devs and it is something I
am considering if and how it could be added to QGIS.  Not something that
I myself will be able to do, way over my head, but more just getting the
ideas out there and maybe some will fund it.

 

Hopefully this will at lest let you understand what is happening.

 

- Nathan



 

 

On Fri, Nov 4, 2011 at 10:01 PM, James Stott
<James.Stott at npaconsult.co.uk> wrote:

I have opened an Access table via an ODBC connection. This has allowed
me to open the attribute table up in QGIS. I have then done a join to
join my attribute and polygon data together. I can style the data using
the joined fields, and they all show up in the attribute table and the
identify tool. However I cannot use these fields in a query. 

 

If I use the query builder the fields show in the fields list, and the
values from the fields show in the field list. However all of my queries
return no results.

 


James Stott BSc (Hons) MSc | Senior Professional
Nicholas Pearson Associates | 30 Brock Street | Bath | BA1 2LN
T: 01225 445548 | M: -
http://www.npaconsult.co.uk/ 


http://www.npaconsult.co.uk/http://www.npaconsult.co.uk/about-news.asp
http://www.npaconsult.co.uk/terms.asp
This Electronic Transmission is intended only for the attention of the addressee. It may contain privileged and confidential information. If you are not the person for whom it is intended, you must not copy, distribute or take any action in reliance on it. If you have received this electronic transmission in error please notify us immediately by telephone, delete the transmission and destroy any hard copies.
Nicholas Pearson Associates has used all reasonable efforts to ensure that this message and any attachments are free from viruses.
Nicholas Pearson Associates, 30 Brock Street, Bath, BA1 2LN , Tel: +44 (0) 01225 445548, Fax: +44 (0) 01225 312387, Website: http://www.npaconsult.co.uk/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20111104/1d392ad4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NPA_Logo.jpg
Type: image/jpeg
Size: 28847 bytes
Desc: NPA_Logo.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20111104/1d392ad4/attachment.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Email_Footer_News.jpg
Type: image/jpeg
Size: 35658 bytes
Desc: Email_Footer_News.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20111104/1d392ad4/attachment-0001.jpg>


More information about the Qgis-user mailing list