I know this is a very basic problem I should be able to solve myself, but I've had no luck. I have a variable I want to use in the query for arcpy.SelectLayerByAttribute, but the line that was working yesterday is now giving me an "error 000358: invalid expression". I simply want to use the variable CountyNM in the where clause.
Here is the section of code giving me issues:
CountyNM = "Hamilton"
arcpy.SelectLayerByAttribute_management("hzCountyLYR", "NEW_SELECTION", 'CountyName =' + "'"+ CountyNM +"'")
Syntax: SelectLayerByAttribute_management (in_layer_or_view, {selection_type}, {where_clause}, {invert_where_clause})
CountyNM = "Hamilton"
toCountyNM = 'Hamilton'
and then use the where_clause:'CountyName = ' + CountyNM
.