I'm wondering if there's anyway to use a wildcard character in a field name. Like using ["Species_%" = 'Hemlock'] instead of ["Species_1" = 'Hemlock' OR "Species_2" = 'Hemlock' ...].

I tried the way that I described but it didn't work. Does anyone know if it's possible with another method within the Select By Attributes window?

  • 3
    No, this is not possible. The best way to accomplish this is to normalize your attributes and have multiple species records per feature; then you can select those which meet the criteria. – Vince Apr 8 '19 at 22:43

You can Paste this function into the Python window of ArcMap. Execute it from the same window. The selected features will be highlighted.

parameters are, select(LayerName, speciesName)
eg. select('wildlife','hemlock')

def select(layerName, species):
    fields = ["objectid","species_1","species_2"]

    mxd = arcpy.mapping.MapDocument("CURRENT")
    lyr = arcpy.mapping.Layer(layerName)

    bCursor = arcpy.da.SearchCursor(lyr,fields)

    # save each Objectid
    selectset = []
    for row in bCursor:
        if str(row[1]).upper() == species.upper():
        elif str(row[2]).upper() == species.upper():

    # build a where_clause such as "Objectid in (2,5,7)"
    if selectset:
        ids = list(set(selectset))
        where_clause = 'Objectid in ({})'.format(','.join(ids))
        arcpy.SelectLayerByAttribute_management (layerName, "NEW_SELECTION", where_clause)
| improve this answer | |

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.