I'm creating a script tool and using the SelectLayerBy Attribute function (below),

arcpy.SelectLayerByAttribute_management("cities_lyr", "NEW_SELECTION", '"CRIME_INDX" <= 0.02')

However, I keep getting this error - ERROR 000358: Invalid expression.

Can anyone please offer some clarity here.

  • 4
    nothing wrong with your expression, but if you are working with a personnal gdb, it should be '[CRIME_INDX] <= 0.02'. I assume that your field is not a text field, of course.
    – radouxju
    Mar 27 '14 at 12:15

Make your expressions as triple quoted strings - nice and clean!

For File geodatabases:

"""CRIME_INDX <= 0.02"""
"""NAME = 'California'"""

For personal geodatabases (.mdb):

"""[CRIME_INDX] <= 0.02"""
"""[NAME] = 'California'"""

Not the answer you're looking for? Browse other questions tagged or ask your own question.