AnsweredAssumed Answered

select by attributes using like

Question asked by chlang5 on Sep 22, 2017
Latest reply on Sep 25, 2017 by bixb0012

I am trying to do a Select By Attributes where I have a field in one street file that has a column "POLICE" that lists the police department like this example: 'Sussex Police' and a file from another source that I am joining that has a column "Police" that lists the police department like this example: 'SUSSEX_POLICE'.  For some names, there may be multiple underscore characters.  I can obviously use UPPER() on the first field to make them almost match, and on the off chance that the data isn't consistent, I'm actually using UPPER on both sides.  I was hoping I could use LIKE to get the underscore vs. the space, but it's just not matching.  So this is my current expression:

 

   where = 'UPPER("EmergencyServiceZones.POLICE") LIKE UPPER("msag_temp.Police")'

   arcpy.SelectLayerByAttribute_management (road_layer, "NEW_SELECTION", where)

 

It returns nothing as it is.

 

Does anyone have any suggestions to adjust the query expression to find the matches?

Outcomes