5

I have an attribute field in my file geodatabase (GDB) where I'm trying to select all records that contain an underbar in the string field. The issue is that the underbar is considered a SQL wildcard on its own.

To illustrate: I need all data similar to "ID" = '42W_42_42E' or "ID" = '31A_31'

Using "ID" LIKE '%_%' returns all records, which isn't helpful. The perfect solution would simply return a count on the number of records with the underbar in their ID attribute.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Mar 30, 2016 at 17:53

1 Answer 1

8

From the page on SQL reference for query expressions used in ArcGIS

To include the percent symbol or underscore in your search string, use the ESCAPE keyword to designate another character as the escape character, which in turn indicates that a real percent sign or underscore immediately follows.

For example, this expression returns any string containing 10%, such as 10% DISCOUNT or A10%:

"AMOUNT" LIKE '%10$%%' ESCAPE '$'

For your case, try the following:

ID LIKE '%$_%' ESCAPE '$'
answered Mar 30, 2016 at 18:17
1
  • Thank you very much, i wasn't aware of the ESCAPE functionality. I searched through the stack pages but somehow overlooked that one. Commented Mar 30, 2016 at 19:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.