5

I am using ArcGIS 10.3.1 and have an attribute that has either 4 or 5 characters; i.e., CO-1, BY-3, CAR-1, MRT-8.

All letters are uppercase, this is in a personal GDB, and this is a string field.

I am trying to select for only the attributes that have 4 characters.

  • 1
    Please edit the question to specify the exact ArcGIS release and the exact type of geodatabases (personal, file, enterprise; if enterprise, which RDBMS). – Vince Sep 2 '15 at 17:48
4

From the help

Use the LIKE operator (instead of the = operator) to build a partial string search. For example, this expression would select Mississippi and Missouri among U.S. state names:

STATE_NAME LIKE 'Miss%'

% means that anything is acceptable in its place: one character, a hundred characters, or no character. Alternatively, if you want to search with a wildcard that represents one character, use _.

Use this: Field_name LIKE '____' (four underscores)

EDIT: That was for a File Geodatabase. For a Personal Geodatabase, the answer would be [Field_name] LIKE '????'

| improve this answer | |
3

As your data is in a personal geodatabase you can simply use:

len([myField]) = 4

This will select all rows where the string in the field "myField" is 4 characters long.

| improve this answer | |
  • This is a python statement, which will not work as a selection query. Selection queries use SQL style syntax. – Adam Sep 3 '15 at 0:17
  • 1
    Actually, this does work in the Select by Attributes dialog. – kenbuja Sep 3 '15 at 12:37
  • @Adam as I understand it the SQL style changes with the underlying database. As Slinn stated he was using a personal geodatabase this is an Access database so you can use the variant of SQL for that. This page lists the type of commands you can use in the Where clause for an Access database. – Hornbydd Sep 3 '15 at 14:00
  • my apologies. i didn't register the personal geodatabase comment. in that case, it works like a charm – Adam Sep 3 '15 at 22:54

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.