Hello Uwe,

you could try this:

select * from my_lines l join my_polys p on l.my_line_attribute like '%' + 
p.my_poly_attribute + '%'

Best regard

Michael

Von: Qgis-user <qgis-user-boun...@lists.osgeo.org> Im Auftrag von Uwe Fischer 
via Qgis-user
Gesendet: Montag, 24. Oktober 2022 13:52
An: qgis-user@lists.osgeo.org
Betreff: [Qgis-user] query for Virtual Layer in relation to another layer


ACHTUNG!! Diese E-Mail erreicht Sie von einem Absender außerhalb der 
niedersächsischen Landesverwaltungs-Infrastruktur mit TLS-Verschlüsselung. 
Bitte klicken Sie auf keine Links oder öffnen Sie keine E-Mail-Anhänge, falls 
Sie den Absender nicht kennen und nicht wissen, ob der Inhalt sicher ist.
Hello,

I am looking for a way to create a virtual layer in 3.24 in a 'special' way. I 
have a line layer with attributes like:

xxxx_123_xxxxxxxxx
oooo_abc_000_123_0

and a polygon layer with attributes like:

abc
123

Now, I would like to use only lines that contain one of the strings that are 
present in the polygon layer.
A prototype for the SQL query might be:

select * from my_lines where my_line_attribute in (select my_poly_attribute 
from my_polys)

The problem is that I cannot use the IN clause because the line attributes 
contain additional surrounding characters around the polygon attributes. The 
surrounding characters can be any token, so it is not possible to remove them 
in a systematic way prior to the query. I thought about working with '%123%'. 
But how do I put every possible value in my_poly_attribute in that clause? That 
is, '%123%' would have to be in the query as well as '%abc%'

Thanks a lot for ideas!

Regards, Uwe

_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to