<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"><head><META content="text/html; charset=utf-8" http-equiv="Content-Type">
    
<META content="text/html; charset=utf-8" http-equiv="Content-Type">


    <STYLE TYPE="text/css">
    <!-- /* Style Definitions */ p.3cc27b56-9d95-4e3a-a964-b3c52ba2f245, li.3cc27b56-9d95-4e3a-a964-b3c52ba2f245, div.3cc27b56-9d95-4e3a-a964-b3c52ba2f245, table.3cc27b56-9d95-4e3a-a964-b3c52ba2f245Table  {margin:0cm; margin-bottom:.0001pt;}div.Section1 {page:Section1;}-->
    </STYLE>
<META content="text/html; charset=utf-8" HTTP-EQUIV="Content-Type"><meta content="Microsoft Word 12 (filtered medium)" name=Generator><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:10.5pt;
        font-family:Consolas;}
span.apple-style-span
        {mso-style-name:apple-style-span;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><BODY STYLE="background-color: #ffffff">
    <P>
        
    <P CLASS="3cc27b56-9d95-4e3a-a964-b3c52ba2f245" STYLE=" margin-bottom:5px;">
        <div class=WordSection1><p class=MsoPlainText>Thanks for the replies. It’s interesting to know how all of this stuff works internally Nathan. <o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>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). <o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>If I use rule based styling I can also select things by attribute and style by attribute.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>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.<o:p></o:p></p><p class=MsoPlainText><o:p> </o:p></p><p class=MsoPlainText>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.<o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p></div></P><P STYLE=" margin-top:5px; margin-bottom: 10px">
        <SPAN STYLE="font-family: 'Verdana','sans-serif'; color: #00227c; font-size: 10pt">
            <STRONG>James Stott</STRONG>
            <SPAN STYLE="font-size: 8pt">BSc (Hons) MSc</SPAN> | 
            Senior Professional<BR>
            <SPAN STYLE="font-size: 8pt"><B STYLE="font-weight: bold">Nicholas Pearson Associates </B> | 30 Brock Street | Bath | BA1 2LN<BR>
                <B>T:</B>
                01225 445548
                 | <B>M:</B>
                -<BR>
                <A HREF="http://www.npaconsult.co.uk/" STYLE="font-family: 'Verdana','sans-serif'; color: #00227c; font-size: 8pt; text-decoration: none;"><STRONG>www.npaconsult.co.uk</STRONG></A>
            </SPAN>
        </SPAN>
        <BR>
        <BR>
        </P>
    <P>
    <div class=WordSection1><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span lang=EN-US style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Nathan Woodrow [mailto:madmanwoo@gmail.com] <br><b>Sent:</b> 04 November 2011 12:38<br><b>To:</b> James Stott<br><b>Cc:</b> qgis-user@lists.osgeo.org; qgis-developer@lists.osgeo.org<br><b>Subject:</b> Re: [Qgis-user] Query a joined layer<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal><span class=apple-style-span><span style='font-family:"Tahoma","sans-serif"'>Hey James,</span></span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><p class=MsoNormal><span class=apple-style-span><span style='font-family:"Tahoma","sans-serif"'>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.</span></span><o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span class=apple-style-span><span style='font-family:"Tahoma","sans-serif"'>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.</span></span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span class=apple-style-span><span style='font-family:"Tahoma","sans-serif"'>Hopefully this will at lest let you understand what is happening.</span></span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span class=apple-style-span><span style='font-family:"Tahoma","sans-serif"'>- Nathan</span></span><span style='font-family:"Tahoma","sans-serif"'><br><br><span class=apple-style-span><o:p></o:p></span></span></p><p class=MsoNormal><span class=apple-style-span><span style='font-family:"Tahoma","sans-serif"'><o:p> </o:p></span></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>On Fri, Nov 4, 2011 at 10:01 PM, James Stott <<a href="mailto:James.Stott@npaconsult.co.uk">James.Stott@npaconsult.co.uk</a>> wrote:<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>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. <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>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.<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p></div></div></P>

    </P>
        <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" STYLE="border: none; outline-style: none; border-collapse: collapse; padding: 0;
            margin: 0;" WIDTH="700">
            <TR>
                <TD>
                    <A HREF="http://www.npaconsult.co.uk/" STYLE="outline-width: 0; border-collapse: collapse; text-decoration: none; outline-style: none;
                        border-style: none; margin: 0; padding: 0;">
                        <IMG ALT="Nicholas Pearson Associates, Logo" BORDER="0" SRC="cid:NPA_Logo.jpg@cfdd8e67.7cbb4aea"></A><A HREF="http://www.npaconsult.co.uk/about-news.asp" STYLE="outline-width: 0; border-collapse: collapse; text-decoration: none; outline-style: none;
                            border-style: none; margin: 0; padding: 0;"><IMG ALT="Nicholas Pearson Associates, Latest News" BORDER="0" SRC="cid:Email_Footer_News.jpg@47e5551a.49344626"></A>
                </TD>
            </TR>
        </TABLE>
        <P STYLE="margin-top: 7.5px; margin-bottom: 7.5px; text-align: left; color: #000000;
            font-size: 7pt; font-family: Verdana;">
            <A HREF="http://www.npaconsult.co.uk/terms.asp" STYLE="text-decoration: none; color: #000000;">
                Information and Registered Address</A>
    </P>
    <P STYLE="margin-top: 5px; margin-bottom: 10px; text-align: left; color: #666666;
        font-size: 7pt; font-family: Verdana;">
        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.
    </P>
    <P STYLE="margin-top: 5px; margin-bottom: 10px; text-align: left; color: #666666;
        font-size: 7pt; font-family: Verdana;">
        Nicholas Pearson Associates has used all reasonable efforts to ensure that this
        message and any attachments are free from viruses.</P>
    <P STYLE="margin-top: 5px; margin-bottom: 10px; text-align: left; color: #666666;
        font-size: 7pt; font-family: Verdana;">
        Nicholas Pearson Associates, 30 Brock Street, Bath, BA1 2LN , Tel: +44 (0) 01225
        445548, Fax: +44 (0) 01225 312387, Website: <A HREF="http://www.npaconsult.co.uk/">http://www.npaconsult.co.uk</A></P>
</BODY></HTML>