whereClause = '"' + crimeField + '" <=' + "'" + crimefieldindex + "'" whereClause2 = '"' + universityField + '" =' + "'" + universityfieldindex + "'"
arcpy.SelectLayerByAttribute_management(citiesL, "NEW_SELECTION", whereClause + "AND" + whereClause2)
import arcpy from arcpy import env env.overwriteOutput = 1 env.workspace = r"C:\Temp\Python\Test.gdb" citiesL = "citiesL" crimeField = "CRIME_INDE" crimefieldindex = "0.02" whereClause = '"' + crimeField + '" <=' + "'" + crimefieldindex + "'" universityField = "UNIVERSITY" universityfieldindex = "1" whereClause2 = '"' + universityField + '" =' + "'" + universityfieldindex + "'" arcpy.MakeFeatureLayer_management("Cities", citiesL) arcpy.SelectLayerByAttribute_management(citiesL, "NEW_SELECTION", whereClause + "AND" + whereClause2) arcpy.CopyFeatures_management(citiesL, "Cities2")
instead of whereClause = ('"' + crimeField + '" <=' + "'" + crimefieldindex + "'") try myfield1 = arcpy.AddFieldDelimiters(lyr,crimeField) whereClause = '{0} <= '{1}''.format(myfield1,crimefieldindex)