[Qgis-user] SQL display expression

Neumann, Andreas a.neumann at carto.net
Tue May 10 06:31:12 PDT 2016


Hi Christoph, 

Are you talking about the left column in the forms view? 

What do you mean by "not related"? Do you mean related, but not
contained in the same table? 

Is this for a value list lookup? 

For a 1:1 relation? 

QGIS expressions don't know "SELECT". The expression always works on a
single feature. It can't return records.  

There could be several ways to do what you want: 

1. use joins (layer properties --> joins) 

2. use the attribute(getFeature(....)) expression 

3. Create a virtual layer (starting from version 2.14) --> see
https://docs.qgis.org/testing/en/docs/user_manual/working_with_vector/virtual_layers.html


I hope that one of the above ways help you solve your problem. 

Greetings, 

Andreas 

On 2016-05-10 14:23, Christoph Lauber wrote:

> Hi 
> 
> 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. 
> 
> 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: ""_pkuid"   ||  ' '  || CASE WHEN art = 1 THEN 'this' ELSE 'that' END_". When I put a select clause in it like "_CASE WHEN "art" THEN (SELECT value FROM WI_D_Inventar_Art WHERE id = "art") ELSE 'Undefined' END_" I get an expression is invalid error (the expression works in spatialite_gui). It seems that the SELECT keyword is not accepted. 
> 
> Is there any possibility to write "free" SQL-Syntax for the display expression? 
> 
> I wrote already a function that connects to the database, fetchs the data and closes the database. It works, but it is slow. 
> 
> Thanks for your help. 
> 
> Freundliche GrĂ¼sse 
> 
> Christoph Lauber 
> 
> *--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*
> GeoplanTeam AG dipl. Ing. ETH/SIA Hutzli+Kluser
> Vermessung | Geoinformatik | Umwelttechnik
> Egliweg 6, CH - 2560 Nidau
> Phone:(+41) - 032 332 78 00
> Fax:(+41) - 032 332 78 01
> Web: www.geoplanteam.ch [1]
> E-Mail: christoph.lauber at geoplanteam.ch
> *--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--* 
> 
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> List info: http://lists.osgeo.org/mailman/listinfo/qgis-user
> Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-user

  

Links:
------
[1] http://www.geoplanteam.ch/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20160510/9c0dc763/attachment.html>


More information about the Qgis-user mailing list