[Qgis-user] query for Virtual Layer in relation to another layer

Uwe Fischer gisfisch at t-online.de
Mon Oct 24 04:51:30 PDT 2022


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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20221024/748fe8df/attachment.htm>


More information about the Qgis-user mailing list