lgelhorn

arcpy.SelectLayerByAttribute returns a subset of the "truth"

Discussion created by lgelhorn on Oct 7, 2011
Latest reply on Oct 11, 2011 by lgelhorn
Hi,

I'm trying to write a python script which selects a number of cases from an attribute table (table view within a file geodatabase) to allow further processing but am getting curious results. It seems as though the query stops once it fullfills the latest condition, regardless of preceeding conditions.  For example:

arcpy.SelectLayerByAttribute_management ("view", "NEW_SELECTION",
  (""" "SP10" = 'WS' """ or """ "SP10" = 'BS' """ or """ "SP10" = 'JP' """  or """ "SP10" = 'BF' """ or  """ "SP10" = 'TL' """)  and (""" "SP11" = 'TA' """ or """ "SP11" = 'BP' """ or """ "SP11" = 'WB' """ or """ "SP11" = 'WE' """ or """ "SP11" = 'MM' """ or """ "SP11" = 'GA' """ ))

will return only those records where SP11 = TA, regardless of the value of SP10.  In this case 13 records are returned. I can find those same 13 records from  using the where condition "SP11" = 'TA'
in the ArcGIS select by attributes dialogue box. Placing the full set of conditions in the select by attributes dialogue box I get a different set of 14 (correct) selected records.

Does anyone have any advice for dealing with this? Others found similar results?

Outcomes