Using ArcGIS Pro 3.2
Here is the SearchCursor with sql_clause
with arcpy.da.SearchCursor('Buildings', "type", sql_clause=("DISTINCT type", None)) as cursor:
for row in cursor:
print(row[0])
office
church
retail
residential
commercial
public
and the UpdateCursor with sql_clause
with arcpy.da.UpdateCursor('Buildings', "type", sql_clause=("DISTINCT type", None)) as cursor:
for row in cursor:
print(row[0])
church
commercial
residential
commercial
commercial
commercial
commercial
retail
church
commercial
retail
commercial
retail
...
UpdateCursor does not honor the DISTINCT sql_clause like the SearchCursor does. Why?
There is an example in the Esri docs
with arcpy.da.UpdateCursor(
in_features,
["OID@", "STREET_NAME"],
sql_clause=("DISTINCT STREET_NAME", None)
) as cur:
~ learn.finaldraftmapping.com