<div dir="ltr"><div>Does someone know which dialect of SQL QGIS uses when working with virtual layers ?</div><div><br></div><div>I have got a shapefile named "subway" and when i run the following query using the DB Manager <br></div><div><br></div><div>SELECT s.gid, s.geometry<br>FROM subway s<br>WHERE (strpos(s.routes, 'Q') <> 0);</div><div><br></div><div>it produces a result that I can add to the map canvas as a virtual layer.</div><div><br></div><div>Such result is in contrast with the QGIS documentation for version 3.22<br></div><div><br></div><div><br></div><div>----------------------------------------------------------------------------------------------------------------------------<br></div><div>
<h2><a class="gmail-toc-backref" href="https://docs.qgis.org/3.22/en/docs/user_manual/managing_data_source/create_layers.html#id24"><span class="gmail-section-number">14.2.5. </span>Creating virtual layers</a></h2>

</div><div> 
The SQL query will be executed, regardless of the underlying provider of the
<code class="gmail-docutils gmail-literal gmail-notranslate"><span class="gmail-pre">airports</span></code> layer, even if this provider does not directly support SQL
queries. <br></div><div><br></div><div>
<h3><a class="gmail-toc-backref" href="https://docs.qgis.org/3.22/en/docs/user_manual/managing_data_source/create_layers.html#id26"><span class="gmail-section-number">14.2.5.2. </span>Supported query language</a><a class="gmail-headerlink" href="https://docs.qgis.org/3.22/en/docs/user_manual/managing_data_source/create_layers.html#supported-query-language" title="Permalink to this headline"></a></h3>
<p>The underlying engine uses SQLite and SpatiaLite to operate.</p>
<p>It means you can use all of the SQL your local installation of SQLite
understands.</p>

</div><div></div><div>--------------------------------------------------------------------------------------------------------------------------</div><div><br></div><div><br></div><div></div><div>
However  the query I have used contains a function 
"strpos" which is not part of the SQL language as understood by SQLite.</div><div><br></div><div>If I run the same query on a layer which is part of a Spatialite database the DB Manager produces the error "no such function: strpos".</div><div><br></div><div>
If I run the same query on a layer which is part of a PostGIS database the DB Manager produces the same result of the virtual layer created from the shapefile.

</div><div><br></div><div></div><div></div><div><br></div><div>So the question is "which dialect does QGIS use for running the query"?</div><div><br></div><div>Does it depend on the type of layer on which the query is applied ?</div><div><br></div><div>Is there a default SQL, which is used in case of a provider that 
does not directly support SQL
queries (such as shapefiles)?<br></div><div><br></div><div><br></div><div>Any info would help.</div><div><br></div><div>Antonio Valanzano</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>