<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Century Gothic";
        panose-1:2 11 5 2 2 2 2 2 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 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
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.E-MailFormatvorlage20
        {mso-style-type:personal;
        font-family:"Century Gothic",sans-serif;
        color:#1F497D;}
span.E-MailFormatvorlage21
        {mso-style-type:personal-compose;
        font-family:"Century Gothic",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
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 lang=DE-CH link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Hi Andreas<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Even my answer comes late…<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>Thanks for your reply and propositions.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>I tried all 3 possibilities and the attribute(getFeature(…)) solution works perfectly for my needs.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'>With “not related” I meant, that the main table and the domain table (list lookup) only have a relation by an intermediate table. I think you understood right </span><span lang=EN-GB style='font-size:10.0pt;font-family:Wingdings;color:#1F497D;mso-fareast-language:EN-US'>J</span><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D'>Freundliche Grüsse</span><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D'>Christoph Lauber<o:p></o:p></span></p></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif;color:#1F497D;mso-fareast-language:EN-US'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span lang=DE style='font-size:11.0pt;font-family:"Calibri",sans-serif'>Von:</span></b><span lang=DE style='font-size:11.0pt;font-family:"Calibri",sans-serif'> Neumann, Andreas [mailto:a.neumann@carto.net] <br><b>Gesendet:</b> Dienstag, 10. Mai 2016 15:31<br><b>An:</b> Christoph Lauber <christoph.lauber@geoplanteam.ch><br><b>Cc:</b> qgis-user@lists.osgeo.org<br><b>Betreff:</b> Re: [Qgis-user] SQL display expression<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>Hi Christoph,<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>Are you talking about the left column in the forms view?<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>What do you mean by "not related"? Do you mean related, but not contained in the same table?<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>Is this for a value list lookup?<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>For a 1:1 relation?<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>QGIS expressions don't know "SELECT". The expression always works on a single feature. It can't return records. <o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>There could be several ways to do what you want:<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>1. use joins (layer properties --> joins)<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>2. use the attribute(getFeature(....)) expression<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>3. Create a virtual layer (starting from version 2.14) --> see <a href="https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/virtual_layers.html">https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/virtual_layers.html</a><o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>I hope that one of the above ways help you solve your problem.<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>Greetings,<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>Andreas<o:p></o:p></span></p><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'>On 2016-05-10 14:23, Christoph Lauber wrote:<o:p></o:p></span></p><blockquote style='border:none;border-left:solid #1010FF 1.5pt;padding:0cm 0cm 0cm 5.0pt;margin-left:0cm;margin-right:0cm'><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>Hi</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>I have a question about the display expression for forms.  The aim is to show data of a table that is not related by QGIS.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>What I would like to do is to write a SQL to my SpatiaLite database to fetch some data. I suppose, that the display expression is restricted to the “select column” clause like: “"<em><span style='font-family:"Century Gothic",sans-serif'>pkuid"   ||  ' '  || CASE WHEN art = 1 THEN 'this' ELSE 'that' END</span></em>”. When I put a select clause in it like “<em><span style='font-family:"Century Gothic",sans-serif'>CASE WHEN "art" THEN (</span></em><strong><i><span style='font-family:"Century Gothic",sans-serif'>SELECT</span></i></strong><em><span style='font-family:"Century Gothic",sans-serif'> value FROM WI_D_Inventar_Art WHERE id = "art") ELSE 'Undefined' END</span></em>” I get an expression is invalid error (the expression works in spatialite_gui). It seems that the SELECT keyword is not accepted.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>Is there any possibility to write “free” SQL-Syntax for the display expression?</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>I wrote already a function that connects to the database, fetchs the data and closes the database. It works, but it is slow.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>Thanks for your help.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>Freundliche Grüsse</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>Christoph Lauber</span><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'><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*<br>GeoplanTeam AG dipl. Ing. ETH/SIA Hutzli+Kluser<br>Vermessung | Geoinformatik | Umwelttechnik<br>Egliweg 6, CH - 2560 Nidau<br>Phone:(+41) - 032 332 78 00<br>Fax:(+41) - 032 332 78 01<br>Web: </span><a href="http://www.geoplanteam.ch/"><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>www.geoplanteam.ch</span></a><br><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>E-Mail: </span><a href="mailto:christoph.lauber@geoplanteam.ch"><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>christoph.lauber@geoplanteam.ch</span></a><br><span style='font-size:10.0pt;font-family:"Century Gothic",sans-serif'>*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Courier New"'>_______________________________________________<br>Qgis-user mailing list<br><a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-user">http://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></span></p></div></blockquote><p><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'> <o:p></o:p></span></p><div><p class=MsoNormal><span style='font-size:10.0pt;font-family:"Verdana",sans-serif'> <o:p></o:p></span></p></div></div></body></html>