4

I created an expression with the help of the GUI in the QGIS attribute table of a vector (shapefile) layer of Native American ("Indian") reservations in the USA state of New Mexico.

"NAME" LIKE 'Picuris'

No row became selected.

The full "NAME" in the desired row is 'Picuris Indian Reservation' . I don't mind typing the whole name, but in principle, is not the LIKE function supposed to find partial matches? That is, if I want 'State Hwy 68' (which is in the FULLNAME field) (of a different layer), will the LIKE operator not find it if I use "FULLNAME" LIKE 'Hwy 68' ?

  • 2
    I think it is better to move your EDIT in a proper answer, (even to mark it as accepted). This way you will eliminate the actual confusion in your question, and your answer will remain as reference for the users with similar issues. – Sorin Călinică Feb 27 '14 at 5:42
  • 1
    You can also just use the "Column Filter" available in the dropdown. This creates a filter-expression LIKE %[needle]% or ILIKE %[needle]% (depending on the "case sensitive" checkbox) for you automatically. You can then use Ctrl+A to select all visible rows. – Matthias Kuhn Feb 27 '14 at 7:45
6

You can also use the column filter of the attribute table. It works default as a 'like' expression without the % wild card.

enter image description here

Result when typing a:

enter image description here

4

[Posted earlier as an "edit" to my own question. Per Sorin's advice, I'm changing this to an answer instead of an edit.]

I think I may have solved it. I used a percent sign ( % ) as a "wild card" along with the LIKE operator, and it looks like I got the expected search results. Example 1: In a roads shapefile layer, "FULLNAME" LIKE '%68%' produced a selection of many roads and highways with the consecutive digits "68" in the name -- such as "State Hwy 68", "State Rte 68", "New Mexico Route 268". Example 2: In a Native American lands shapefile layer, "NAME" LIKE 'A%' produced a selection of "Acoma Indian Reservation" and "Alamo Navajo Indian Reservation".

  • Catlike, thank you - I was looking for this syntax so long ... :) – user29347 Mar 1 at 8:18

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.