New Map Viewer and Classic cannot handle underscore in Filters

650
4
Jump to solution
10-13-2021 07:48 AM
DougBrowning
MVP Esteemed Contributor

The New Map Viewer does not handle underscore correctly in a filter.  It seems to do nothing.  Looks like maybe escape was not programmed in?  I just checked and the classic viewer does not work either.

DougBrowning_0-1634136152084.png

In Python it is 

whereClause = "RecKey LIKE '%$_' ESCAPE '$' Or RecKey LIKE '$_%' ESCAPE '$'"

Is there a way to use escape or similar?

thanks

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Try using brackets to escape wildcards. It appears your guess is right, ESCAPE doesn't really do anything.

Here's a feature w/ an underscore.

jcarlson_0-1634139920478.png

Filtering for "contains _":

jcarlson_1-1634139958390.png

(For the record, those other features do not have underscores.)

Filtering for "contains [_]":

jcarlson_2-1634140006122.png

 

- Josh Carlson
Kendall County GIS

View solution in original post

4 Replies
jcarlson
MVP Esteemed Contributor

Try using brackets to escape wildcards. It appears your guess is right, ESCAPE doesn't really do anything.

Here's a feature w/ an underscore.

jcarlson_0-1634139920478.png

Filtering for "contains _":

jcarlson_1-1634139958390.png

(For the record, those other features do not have underscores.)

Filtering for "contains [_]":

jcarlson_2-1634140006122.png

 

- Josh Carlson
Kendall County GIS
DougBrowning
MVP Esteemed Contributor

Well that worked.  Where did you find that?  Is it documented?

Thanks

0 Kudos
jcarlson
MVP Esteemed Contributor

I've no idea if it's documented in the ESRI-verse anywhere, but I had to do a similar filter once and saw this in the MS SQL docs: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/like-transact-sql?view=sql-server-ver15...

- Josh Carlson
Kendall County GIS
0 Kudos
DougBrowning
MVP Esteemed Contributor

I did not even try it since [] does not work on a GDB.  I have found the SQL to be slightly diff for each place in Arc, which is a major pain.  I found things like CAST works on a GDB but not a in_memory set.  https://community.esri.com/t5/data-management-questions/using-sql-cast-functionality-in-against-a-fi...

Wish it was all consistent.  Thanks

0 Kudos