I have a punctual shapefile containing the name of geographic locations (attribute 'name')

Using DB Manager of Qgis, I would like create an SQL query to find, within the shape, the name of a location and, and therefore its point. I would like to find the name of the location even by writing only one part.

For example: The name of location is 'Torretta'. Just writing "Torr", I would like to find all the locations that contain the word "Torr" (without considering the upper case and lower case letters).


One example working with QGIS Alaska dataset:

FROM "airports"
WHERE lower("NAME")  LIKE lower('%Big%') 
  • FROM: your shapefile layer shown as a Virtual Layer
  • "NAME" is "name" in your case
  • '%Big%' would be '%Torr%'

enter image description here

Hitting [Load now!] button (at lower right corner), selected Big Lake and Big Mountain AFS appear as a new QueryLayer.

enter image description here

EDIT To narrow down the selection by using both "name" and "town", please add AND keyword.

FROM "your_shapefile_layer"
WHERE lower("name") LIKE lower('%Torr%') AND lower("town") LIKE lower('%potenza%')
| improve this answer | |
  • next step: in the same shape I also have an attribute "town". I would like add to quary both the search by "name" and by "town". For example: searching only the location 'Torretta' of town "potenza" – Giuseppe Cillis Nov 19 '17 at 10:23
  • Thanks @GiuseppeCillis Please see the bottom of my answer (marked EDIT). Please let me know if it does not work. – Kazuhito Nov 19 '17 at 10:37
  • Yes!! It work perfectly !! – Giuseppe Cillis Nov 20 '17 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.