A query that will select features from a file geodatabase field containing specific characters

03-15-2017 01:15 PM
New Contributor II

I’m trying to write a query that will select features from a file geodatabase string field containing specific characters. The format of the string is “12_XYZ_XYZ_WXYZ_A_C01C_+##” The specific part I am trying to search for is the first letter C, which describes what that particular feature is. It can also be A, B, or D. I need a way to select all the features that contain either “A”, “B”, and so on. I’ve tried several different queries using *, ?, and % as wildcards but none have worked so far. Any assistance would be greatly appreciated.

0 Kudos
2 Replies
Occasional Contributor III

Read that link it will be helpful:

SQL reference for query expressions used in ArcGIS—Help | ArcGIS Desktop 

read LIKE Expressions in the string paragraph.

The wildcards you use to conduct a partial string search also depend on the data source you are querying. For example, in a file-based or ArcSDE geodatabase data source, this expression would select Mississippi and Missouri among USA state names:


The percent symbol (%) means that anything is acceptable in its place—one character, a hundred characters, or no character. The wildcards you use to query personal geodatabases are asterisk (*) for any number of characters and question mark (?) for one character.

0 Kudos
MVP Esteemed Contributor

Given the structure of your string, and what you are trying to achieve, I don't think using LIKE with wildcards is the best approach.  Using the same documentation referenced by Abdullah Anter‌, I suggest using SUBSTRING:

SUBSTRING(field FROM 19 for 1) in ('A', 'B', 'D')