I know that on PostgreSQL I can filter columns using a regular expression as the following:
select * from mytable WHERE mycolumn ~ '^word.*'
It works perfectly fine on PostregreSQL. However if I try this same syntax on SpatiaLite I see the following message: SQL error: near "~": syntax error
. Then, I thought SpatiaLite would use the same syntax as SQLite, so I found this solution on StackOverflow that's a database-related question. However, using select * from mytable WHERE mycolumn REGEXP '^word.*'
hasn't solved the problem as well... So I think it's more a syntax issue with SpatiaLite than an SQL problem here. I've searched words like regex
and regular expression
on the SpatiaLite documentation but it doesn't mention this subject there. Is it a limitation from SpatiaLite? Can I search values inside a SpatiaLite database using a regular expression?
select 1 where 'a' REGEXP 'b';
say? That's about the minimal regex test you can do in sqlite3 (should return nothing, replace'b'
with'a'
and it should return "1").REGEXP
works fine. It partially solves the problem because now I can extract the information that I want withogr2ogr
, but on the other hand I don't know if it's possible to load this module onspatialite-gui
(I've tried using.load /usr/lib/sqlite3/pcre.so
inside its gui interface but it didn't work.select load_extension('/usr/lib/sqlite3/pcre.so');
mycolumn
has null values so I need to useis not NULL
with it as well (I spent some time figuring it out here).