<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Hi Christoph,</p>
<p>Are you talking about the left column in the forms view?</p>
<p>What do you mean by "not related"? Do you mean related, but not contained in the same table?</p>
<p>Is this for a value list lookup?</p>
<p>For a 1:1 relation?</p>
<p>QGIS expressions don't know "SELECT". The expression always works on a single feature. It can't return records. </p>
<p>There could be several ways to do what you want:</p>
<p>1. use joins (layer properties --> joins)</p>
<p>2. use the attribute(getFeature(....)) expression</p>
<p>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></p>
<p>I hope that one of the above ways help you solve your problem.</p>
<p>Greetings,</p>
<p>Andreas</p>
<p>On 2016-05-10 14:23, Christoph Lauber wrote:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored --><!-- meta ignored -->
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif;">Hi<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><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.<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><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>pkuid" || ' ' || CASE WHEN art = 1 THEN 'this' ELSE 'that' END</em>”. When I put a select clause in it like “<em>CASE WHEN "art" THEN (<strong>SELECT</strong> value FROM WI_D_Inventar_Art WHERE id = "art") ELSE 'Undefined' END</em>” I get an expression is invalid error (the expression works in spatialite_gui). It seems that the SELECT keyword is not accepted.<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">Is there any possibility to write “free” SQL-Syntax for the display expression?<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">I wrote already a function that connects to the database, fetchs the data and closes the database. It works, but it is slow.<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">Thanks for your help.<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">Freundliche Grüsse</span><span style="mso-fareast-language: DE-CH;"><!-- o ignored --></span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">Christoph Lauber<!-- o ignored --></span></p>
<p class="MsoNormal"><span style="mso-fareast-language: DE-CH;"><!-- o ignored --> </span></p>
<p class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*<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><span style="mso-fareast-language: DE-CH;"><a href="http://www.geoplanteam.ch/"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; color: blue;">www.geoplanteam.ch</span></a><br /></span><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">E-Mail: </span><span style="mso-fareast-language: DE-CH;"><a href="mailto:christoph.lauber@geoplanteam.ch"><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; color: blue;">christoph.lauber@geoplanteam.ch</span></a><br /></span><span style="font-size: 10.0pt; font-family: 'Century Gothic',sans-serif; mso-fareast-language: DE-CH;">*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*<!-- o ignored --></span></p>
<p class="MsoNormal"><!-- o ignored --> </p>
</div>
<!-- html ignored --><br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">_______________________________________________<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></div>
</blockquote>
<p> </p>
<div> </div>
</body></html>